# Golf a golf-scorer

### Python 2, ~~72~~ 70 bytes

```
f=lambda x,*T:[x*(-1)**T.count(x),~x%2*15,-x][(x-3)/8]+(T>()and f(*T))
```

At one point I wished Python treated `0**0 == 0`

for once so that I could do `(-condition)**num`

. Call like `f(11, 10, 3, 1, 2, 2)`

.

Previous 72-byte version:

```
f=lambda x,*T:[~x%2*15,x*(-1)**(x<3or T.count(x))][x<11]+(T>()and f(*T))
```

## ><>, ~~63 57~~ 56+2 = ~~65 59~~ 58 bytes

The input numbers are expected to be on the stack at program start, so +2 bytes for the `-v`

flag. Try it online!

```
</!?lp6$+1g6:
3\0
?\::6g2%*{+}1+:b=
;\~16g-26g2*-c6gf*+n
```

As all unused values in the code field are initialised to `0`

, it can be used to work out how many of each value is present on the stack by getting the value at `[value,6]`

, incrementing it, and putting it back in the code field. The total is then calculated as:

```
T = 0 + {for x in 3 to 10, x*([x,6]%2)} - [1,6] - 2*[2,6] + 15*[12,6]
```

*Edit: golfed 6 bytes off by restructuring the input and switching the calculation steps around. Previous version:*

```
:6g1+$6pl0=?\
/-*2g62-g610/
c ;n$\
6:b=?/>::6g2%*{+}1+!
\gf*+3/
```

*Edit 2: saved 1 byte, thanks to Sp3000*

## MATL, ~~27~~ 26 bytes

```
3:10=s2\7M*G12=15*Gt3<*_vs
```

The input is a column array, that is, values are separated by semicolons.

Try it online! or verify all test cases (this adds a loop to take all inputs, and replaces `G`

by `1$0G`

to push latest input).

### Explanation

```
3:10= % Take input implicitly. Compare with range [3 4 ... 10], with broadcast
s % Sum of each column: how may threes, fours, ... tens there are
2\ % Modulo 2
7M % Push [3 4 ... 10] again
* % Element-wise multiply (the sum of this array is the score of 3...10)
G % Push input again
12= % Compare with 12, element-wise
15* % Multiply by 15 (this is the score of 12)
G % Push input again
t3< % Duplicate. True for entries 1 or 2
*_ % Multiply and negate (the sum of this array is the score of 1, 2)
v % Concatenate all stack concents into a vertical array
s % Sum of array. Implicitly display
```