[Question]
  [
Okay, so yesterday was 2nd Christmas day and my (grand)parents and me had a game of "sjoelen", as it is called in the Netherlands. The inner programmer came up in me, but just when I had the answer, I lost it. I want you to remake it.
*The rules:*
You have a wooden plank, a *sjoelbak*, with 4 boxes, each with their own number. When a *schijf* (A puck-like object) goes in one of the boxes you get the points above that box.
![A _sjoelbak_ with _schijven_](https://i.stack.imgur.com/wv2rm.jpg)  
When there is a *schijf* in all 4 of the boxes, you don't get 10 but you get 20 points.
*Example:*
From left to right: 3 5 4 3  
Each box has at least 3 *schijven* (Plural of *schijf*) so that is 20 \* 3 = 60 points.
Resulting values: 0 2 1 0  
0\*2 + 2\*3 + 1\*4 + 0\*1 = 10 points.  
Which makes a total of 60+10 = 70 points.
*The input:*  
The amount of *schijven* from left to right, ie "4 5 4 5", [4,5,4,5], "4\n5\n4\n5", whatever you like.
*The output:*  
The amount of points, ie 84, as output, variable, return or on top of the stack, whatever you like.
As in each and every code golf, you can not use external scripts and the code with the least bytes wins.
PS: As you may have already noticed, I'm Dutch. Feel free to edit possible grammar mistakes.
  
[Answer]
# CJam, ~~23 21~~ 20 bytes
```
q~_$0=f+1m>{X):X*+}*
```
I might be able to golf a couple of bytes off this.
Input is like
```
[3 5 4 3]
```
Output is the score
```
70
```
**How it works**
```
q~                         "Read the input and evaluate into an array";
  _$0=                     "Copy the array, sort it and get the minimum number";
                           "This minimum is the number of common schijven";
      f+                   "Increment each of the schijven by the common schijven number"; 
        1m>                "Take 1 element from the end of the array and put";
                           "it in the beginning";
           {      }*       "Reduce the elements of the array based on this block";
            X):X           "Increment and update the value of X (initially 1)";
                *          "Multiply the number of schijven with X";
                 +         "Add it to current score";
```
**Algorithm**
* Since I have right shifted the number of schijven, the score order now becomes `[1 2 3 4]`.
* Moreover, using the fact that `1 + 2 + 3 + 4 = 10`, I simply add the minimum common schijven to each one to get the effect of bonus `10` score.
* Now when I reduce, I get 2 elements initially on stack, the first one, which I ignore is the one with a score of `1` each, then I multiply the second one with `2` and add it to first. In the next iteration, I get the current sum and score `3` schijven. And so on.
[Try it online here](http://cjam.aditsu.net/)
[Answer]
# Piet, 240 (30\*8) codels, 138 containing actual code
Codel size 10, for better visibility
![Piet: sjoelen point count](https://i.stack.imgur.com/SkMSc.png)
Test examples:
```
D:\codegolf\npiet-1.3a-win32>npiet sjoelen_point_count_cs10.png
? 3
? 5
? 4
? 3
70
D:\codegolf\npiet-1.3a-win32>npiet sjoelen_point_count_cs10.png
? 4
? 5
? 4
? 5
84
```
Flow display:
Using my own shorthand for easier handling and compact display.
It shows the general program flow, not the exact locations of the codels.
```
NOP ADD DIV GRT DUP INC END
 0   +   /   >   =   c   ~
PSH SUB MOD PTR ROL OUN
 X   -   %   #   @   N
POP MUL NOT SWI INN OUC
 ?   *   !   $   n   C
1X!nnnn=5X2X@=5X2X@=5X2X@=5X1X@**
       0                        *
       0       @+5X1X@1X-4X1X@  !
       0       -             0  !
       0       X1!X1X6+*==X40000#  <--pointer if top of stack=1 (all boxes full,
       0                     0  2      add 20 points, decrement count for all boxes)
       0000-X1@X1X2-X1@X1X3-X1  X  |  pointer if top of stack=0 (not all boxes full,
                                *  V   add 2a+3b+4c+d)
           ~N++++*X4@X2X3*X3@X1X2
```
Full explanation:
```
      (score=0)  a   b   c   d
      1 PSH NOT INN INN INN INN
      ..... sort and duplicate the numbers .....
**1** DUP 5 PSH 2 PSH ROL DUP 5 PSH 2 PSH ROL DUP 5 PSH 2 PSH ROL DUP 5 PSH 1 PSH ROL
      ( a*b*c*d ) (convert to boolean) 1 if all boxes are full, 0 if at least one box is empty
      MUL MUL MUL NOT NOT
      change direction if 1 (**2**)
      go straight ahead if 0 (**3**)
      PTR
      ( compress 20=4*4+4 )       (0-1=-1/ neg. roll) score+20
**2** 4 PSH DUP DUP MUL ADD 6 PSH 1 PSH NOT 1 PSH SUB ROL ADD
      (put score back to bottom of stack) ... a=a-1, b=b-1, c=c-1, d=d-1 ...
      5 PSH 1 PSH ROL 1 PSH SUB 4 PSH 1 PSH ROL 1 PSH SUB 3 PSH
      1 PSH ROL 1 PSH SUB 2 PSH 1 PSH ROL 1 PSH SUB
      loop to **1**
      (   a*2   )               (   b*3   )               (  c*4  )
**3** 2 PSH MUL 2 PSH 1 PSH ROL 3 PSH MUL 3 PSH 2 PSH ROL 4 PSH MUL
      +2a +3b +d +score
      ADD ADD ADD ADD
      output score
      OUN
```
Save the image and try it out in this online Piet interpreter:
[PietDev online Piet interpreter](http://www.rapapaing.com/blog/?page_id=6)
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), ~~16~~ ~~13~~ 12 bytes
-3 thanks to @Adám
```
(+/+\)1⌽⌽+⌊/
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v9fQ1tfO0bT8FHPXiDSftTTpf8/7VHbhEe9fY@6mg@tN37UNvFR39TiomQgWZKRWfy/BChb/ah366POhUVAZtqj3l1W6vnZ6o@6W9TTEjNz1IECQOmiWi5jBVMFEwVjhRIFcwMuEzDHFMixMAEA "APL (Dyalog Classic) – Try It Online")
`⌽+⌊/` reverse(arg) + min(arg)
`1⌽` rotate 1 to the left
`+\` partial sums
`+/` sum
[Answer]
# Mathematica, ~~38~~ ~~32~~ ~~23~~ 20 bytes
```
(#+Min@#).{2,3,4,1}&
```
(With help from *swish*)
Use by tacking the input on to the end:
```
(#+Min@#).{2,3,4,1}&@{3,5,4,3}
70
```
Alternate (36 bytes):
```
20*Min@#+Total[(#-Min@#)*{2,3,4,1}]&
```
[Answer]
# R, ~~41~~ 40 chars
```
b=min(a<-scan());sum(5*b+(a-b)*c(2:4,1))
```
Usage:
```
> b=min(a<-scan());sum(5*b+(a-b)*c(2:4,1))
1: 4 5 4 5
5: 
Read 4 items
[1] 84
> b=min(a<-scan());sum(5*b+(a-b)*c(2:4,1))
1: 3 5 4 3
5: 
Read 4 items
[1] 70
```
In the last example, `a` is vector `3 5 4 3`, `a-b` is `0 2 1 0`, which we multiply with vector `2 3 4 1` thus giving `0 6 4 0` which we add with `5*b` giving `15 21 19 15` (`5*b` being recycled for each member of the added vector, hence effectively adding `4*5*b`), which we finally sum, thus giving `70`.
[Answer]
# JavaScript (ES6), ~~93~~ 47 bytes
```
s=(a,b,c,d)=>10*Math.min(a,b,c,d)+a*2+b*3+c*4+d
```
Usage: `s(1, 2, 3, 4)`
How it works: the function looks for the smallest number in the arguments, and multiplies that by `10` (not with `20`) and adds the rest of the score. It's not necessary to multiply by `20` and substract parts from the score to continue the calculation.
Thanks to edc65 for sharing improvements!
Un-golfed:
```
function score(a, b, c, d) {
    return 10 * Math.min(a, b, c, d) + a * 2 + b * 3 + c * 4 + d;
}
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 15
```
sm*hd+@QtdhSQUQ
```
Input should be given comma separated on STDIN, e.g.
```
3,5,4,3
```
This uses the same trick that many other solutions have used, of adding the minimum to each element to account for the bonus. The minimum is `hSQ` in the above code. To account for multiplying by 2, 3, 4, and 1, I map d over the list [0,1,2,3], and multiply the (d-l)th element of the input by d+1. Thus, the -1th element is multiplied by 1, the zeroth by 2, the first by 3 and the second by 4. Then I sum.
[Answer]
# J, ~~23~~ 22 chars
```
   (+/ .*&2 3 4 1@(+<./))
```
Example:
```
   test =. 3 5 4 3
   (+/ .*&2 3 4 1@(+<./)) test
70
```
[Try it here.](http://tryj.tk/)
(23 long explicit function definition: `v=:3 :'+/+/\.3|.y+<./y'`)
[Answer]
# [Ostrich v0.1.0](https://github.com/KeyboardFire/ostrich-lang/releases/tag/v0.1.0-alpha), ~~48~~ 41 characters (way too long)
```
.$0={}/:n;{n-}%)\+1:i;{i*i):i;}%{+}*20n*+
```
This is simply the same as the old version below, except that instead of using `@` to rotate the whole stack, `)\+` (right uncons) is used instead.
Old version:
```
.$0={}/:n;{n-}%{}/{4@}3*1:i;]{i*i):i;}%{+}*20n*+
```
I have actually discovered two bugs in my very newly implemented language, annotated in the description below. (The language is currently very, very similar to Golfscript, so if you know Golfscript it should be fairly easy to read.
```
.$0=   get min value (for the *20 thingy)
{}/    *actually* get min value (BUG: `array number =' returns a single-element array...)
:n;    store as n
{n-}%  subtract this value from all array elements
{}/    dump array onto stack
{4@}3* rotate stack so that instead of 2 3 4 1, multipliers are 1 2 3 4
       (BUG: negative rotations don't work)
1:i;   set i (the multiplier) to 1
]{i*   multiply each array element by i
i):i;  increment i
}%     (do the previous 2 lines over each array element)
{+}*   add up all the array elements
20n*+  add 20*n (the min value we got in line 1)
```
Expects input as an array on STDIN, because I'm a doorknob and forgot to implement I/O in v0.1.0.
Solving an actual problem in Ostrich is nice, because it shows me exactly how much more stuff I need to add to the language :D
[Answer]
# Python 2, 43 bytes
```
lambda i:i[1]-i[3]+2*(sum(i)+i[2]+5*min(i))
```
Inspired by @user2487951's answer.
[Answer]
# [Jagl](http://github.com/globby/jagl) Alpha 1.2 - 20 bytes
Input is in stdin in format `(3 4 5 6)`, output is left on stack:
```
T~dqZ*S1 5r]%{U*}/b+
```
~~Waiting for a response from the original poster about the output format. Since input is specified as *"whatever you like"*, I am going to assume that my input can be an array on the top of the stack.~~ Now takes input on stdin.
Explanation:
```
T~                            Get input from stdin and evaluate
  dqZ*                      Duplicate, get minimum, and multiply that by 10
      S1 5r]                Swap (so array is on top), push range 1-5 exclusive, and rotate
            %{U*}/          Zip arrays together, and multiply each pair
                  b+P       Get the sum of that, add the common minimum, and print
```
[Answer]
# Haskell, 40
```
g l@[a,b,c,d]=2*a+3*b+4*c+d+10*minimum l
```
instead of removing the minimum number from the rest and adding additional `20`s, this adds additional `10` for the minimum number.
[Answer]
# Matlab, 27
Took me a while to understand that it is single player game. With the help of anonymous function
```
f=@(N)N*[2;3;4;1]+10*min(N)
```
which is invoked with row vector
```
f([3 5 4 3]) == 70
f([7 7 9 7]) == 148
```
[Answer]
# Java, 84 bytes
```
int A(int[]a){int m=9;for(int i:a)m=i<m?i:m;return 10*m+a[3]+2*a[0]+3*a[1]+4*a[2];}
```
I have the idea this can be golfed any further, but this is it for now.
Call with `A(new int[]{3,5,4,3})`, output is returned as int (Because `System.out.println()` would double the bytes)
Ungolfed
```
int getScore(int[] input){
    int min=9;
    for(int x:input) {
        if(x<min){
            min=x;
        }
    }
    return 10*min + 2*input[0] + 3*input[1] + 4*input[2] + 1*input[3];
}
```
[Answer]
# GolfScript, 22 bytes
```
~3,{1$>~;}%+$(11*+{+}*
```
Reads input from stdin, in the format `[3 5 4 3]`. Writes output to stdout. (If taking the input as an array on the stack is allowed, the leading `~` may be omitted for a total of 21 bytes.)
This uses a somewhat different strategy than the CJam / Pyth / etc. solutions: I first build an array with 2 copies of the first input value, 3 of the second, 4 of the third and one of the fourth. Then I sort this array, pull out the smallest element, multiply it by 11 and sum it with the other elements.
[Answer]
## Python 2, 51
Uninspired, but short:
```
l=input()
print l[0]*2+l[1]*3+l[2]*4+l[3]+10*min(l)
```
More pythonic:
```
l=input()
print sum(map(lambda x,y:x*y,l,[2,3,4,1]))+10*min(l)
```
[Answer]
# Julia, ~~48~~ 35 characters
~~`function p(m);sum([2 3 4 1].*m)+10minimum(m);end`~~
in compact assignment form:
```
p(m)=sum([2 3 4 1].*m)+10minimum(m)
```
Example:
```
julia> p([3 5 4 3])
70
```
[Answer]
# Javascript, 97 bytes
```
a=prompt().split(" "),b=Math.min.apply(1,a);alert(20*b+2*(a[0]-b)+3*(a[1]-b)+4*(a[2]-b)+(a[3]-b))
```
[Answer]
# Javascript, ES6, 57
```
f=(a,b,c,d)=>a*b*c*d?20+f(--a,--b,--c,--d):a*2+b*3+c*4+d
```
I wanted to see how recursion would turn out, and while it is definitely not the shortest answer, I felt like it turned out well.
**`a*b*c*d`**: It takes the input values and finds the product of all of them, and evaluate that as a Boolean expression for an inline if statement. This will return false if one or more of the values is 0, and true for any other value. 
**`20+f(--a,--b,--c,--d)`**: If it returns true, the function returns 20 (for the *schijven* set) plus the recursive call of the function for all of the values minus one (To remove that *schijven* set). In this way it will recursively loop through until at least one of the boxes is empty. 
**`a*2+b*3+c*4+d`** After at least one box it empty, the else part of the inline if statement will run. It just returns the points for the remaining *schijven* in the boxes.
Thus at the end all of the 20 point *schijven* sets, and the remanding points are summed up and returned from the function, producing the answer. 
[Answer]
# Haskell 42 chars
```
f l=10*minimum l+sum(zipWith(*)[2,3,4,1]l)
```
[Answer]
# HPPPL (HP Prime Programming Language), ~~58~~ 57 bytes
The \* between 10 and min isn’t necessary, so I removed it.
```
EXPORT s(m)
BEGIN
return sum([2,3,4,1].*m)+10min(m);
END;
```
HPPPL is the programming language for the HP Prime color graphing calculator/CAS.
Example runs:
[![HPPPL screen capture of sjoelen point count program](https://i.stack.imgur.com/C8N8V.png)](https://i.stack.imgur.com/C8N8V.png)
If it doesn’t have to be a program, then it’s realizable in a ~~40~~ 39 bytes one-liner:
```
m:=[3,5,4,3];sum([2,3,4,1].*m)+10min(m)
```
[Answer]
# Staq, 72 characters
```
't't't't{aii*XX}$&iia$&ia$&a+XX+XX+|{mxx}{lxX}{k>?m!l}kkk&iiqi&ii*s*t|+:
```
Example run:
```
Executing D:\codegolf\Staq\sjoelen codegolf.txt
3
5
4
3
70
Execution complete.
>
```
Staq has two stacks, one active, one passive. The `|` command switches the active stack to passive and vice versa.
Everything between curly braces defines a function, the first letter after the opening brace is the function name, the rest until the closing brace is the function itself. Overriding functions, recursion and nested functions are possible. `{aii}` would define a function *a* that would increment the top of the stack twice. Every following instance of `a` in the code will be replaced by `ii`.
Comments inside *Staq* prorams:
`&` adds a zero on top of the stack, `[` instructs the pointer to jump to the corresponding `]` if the top of the stack is zero, `x` deletes the topmost value on the stack. So, comments can be written into the code in the form of `&[here is a comment]x`
Explanation (also executable):
```
'                                      &[input number]x
 t                                     &[copy top of active stack to passive stack]x
  t't't                                &[input next three numbers and copy them to the passive stack]x
       {aii*XX}                        &[define function a (increment twice, multiply the two topmost values, then delete the second value on the stack twice)]x
               $                       &[move top value to the bottom of the stack]x
                &ii                    &[put zero on top of the stack, incremment twice]x
                   a                   &[function a]x
                    $&ia$&a
                           +           &[put sum of the two topmost values on top of the stack]x
                            XX         &[delete second stack value, twice]x
                              +XX+
                                  |    &[switch active/passive stack]x
{mxx}                                  &[define function m: delete two topmost stack values]x
     {lxX}                             &[define function l: delete topmost stack value, then delete second value of remaining stack]x
          {k>?m!l}                     &[define function k: boolean top > second value? put result on top of the stack, if top>0 then execute m, if top = 0 then execute l]x
                  kkk&ii
                        q              &[put square of top value on top of the stack]x
                         i&ii
                             *         &[multiply two topmost values and put result on top of the stack]x
                              s        &[move bottom stack value to the top]x
                               *t|+
                                   :   &[output result]x
```
<https://esolangs.org/wiki/Staq>
The program uses one stack (initially active) to calculate 2a+3b+4c+d, and the second stack (initially passive) to calculate 10 times the minimum of the input values. Then both results are summed up and displayed.
[Answer]
# [PowerShell for Windows](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~48~~ 47 bytes
-1 byte thanks to mazzy
```
$args|%{$a+=++$i%4*$_+$_}
$a+10*($args|sort)[0]
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfmvkmZb/V8lsSi9uEa1WiVR21ZbWyVT1URLJV5bJb6WCyhiaKClAVFQnF9UohltEPu/lotLTSVNwQACwWxDJLYBhAdXY4jEBvLAbBMFYwUjFLYRmG2sYAri/wcA "PowerShell – Try It Online")
]