[Question]
  [
As a kid, I used to play the card game *"[golf](https://en.wikipedia.org/wiki/Golf_(card_game))"* a lot. Your challenge, should you choose to accept it, is to calculate the score of a golf hand. Since there are over 9000 variations on this card game1, we will go with the rules I remember playing.
# Rules (of the game)
* You end a round with 6 cards, and you want as few points as possible.
* Jokers are not used.
* Aces and 2s are worth -1, and -2 points respectively.
* Jacks and Kings are both worth 0 points.
* Cards from 3 to 10 are worth face value. However, these are cancelled when you pair them off. For example, a 5 is worth 5 points, but two 5s are worth zero. Three 5s are worth 5 points, (since the first 2 are paired off, but the 3rd is not.) and four 5s are worth 0 (since it makes 2 pairs).
* Queens are worth 15 points. Queens cannot be cancelled, e.g. 2 queens are worth 30 points.
# Rules (of the challenge)
Input will be an array of integers, or 6 individual integers. Whichever one you prefer. 1 represents an ace, 2-10 represents 2-10, and Jack, Queen, and King represents 11, 12, and 13. Output is the score of the hand according to the rules above. You can safely assume that all inputs are valid, e.g. no number appears more than 4 times, and all numbers are in the range `[1, 13]`. Input and output can be in any reasonable format.
# Test IO:
```
[11, 10, 3, 1, 2, 2]    --> 8
[4, 5, 5, 3, 8, 7]      --> 22
[2, 2, 2, 2, 1, 1]      --> -10 (The lowest score possible)
[12, 12, 12, 12, 10, 9] --> 79 (The highest score possible)
[9, 9, 9, 9, 11, 1]     --> -1
[8, 8, 8, 8, 11, 13]    --> 0
[10, 9, 3, 7, 12, 2]    --> 42
[1, 2, 3, 4, 5, 6]      --> 15
[10, 9, 2, 3, 4, 1]     --> 23
[10, 3, 12, 3, 7, 12]   --> 47
```
Shortest answer in bytes wins!
---
*1not really, but there are a lot of variations.*
  
[Answer]
## 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))
```
[Answer]
# [><>](https://esolangs.org/wiki/Fish), ~~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!](http://fish.tryitonline.net/#code=PC8_PTBscDYkKzFnNjoKM1wwCj9cOjo2ZzIlKnsrfTErOmI9CjtcfjE2Zy0yNmcyKi1jNmdmKitu&input=&args=LXYgMTA+LXYgMw+LXYgMTI+LXYgMw+LXYgNw+LXYgMTI)
```
</!?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*
[Answer]
# [MATL](https://github.com/lmendo/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!](http://matl.tryitonline.net/#code=MzoxMD1zMlw3TSpHMTI9MTUqR3QzPCpfdnM&input=WzEwOyA5OyAzOyA3OyAxMjsgMl0) or [verify all test cases](http://matl.tryitonline.net/#code=YAozOjEwPXMyXDdNKjEkMEcxMj0xNSoxJDBHdDM8Kl92cwpEVA&input=WzExOyAxMDsgMzsgMTsgMjsgMl0gICAgCls0OyA1OyA1OyAzOyA4OyA3XSAgICAgIApbMjsgMjsgMjsgMjsgMTsgMV0gICAgICAKWzEyOyAxMjsgMTI7IDEyOyAxMDsgOV0gCls5OyA5OyA5OyA5OyAxMTsgMV0gICAgIApbODsgODsgODsgODsgMTE7IDEzXSAgICAKWzEwOyA5OyAzOyA3OyAxMjsgMl0gICAgClsxOyAyOyAzOyA0OyA1OyA2XSAgICAgIApbMTA7IDk7IDI7IDM7IDQ7IDFdICAgICAKWzEwOyAzOyAxMjsgMzsgNzsgMTJd) (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
```
[Answer]
# Pyth - ~~37~~ ~~36~~ 35
This is seems way too large, but FGITW.
```
J<#h;K-QS2++*15/K12sm*d%/Jd2{J_s@S2
```
[Test Suite](http://pyth.herokuapp.com/?code=J%3C%23h%3BK-QS2%2B%2B%2a15%2FK12sm%2ad%25%2FJd2%7BJ_s%40S2&test_suite=1&test_suite_input=%5B11%2C+10%2C+3%2C+1%2C+2%2C+2%5D%0A%5B4%2C+5%2C+5%2C+3%2C+8%2C+7%5D%0A%5B2%2C+2%2C+2%2C+2%2C+1%2C+1%5D%0A%5B12%2C+12%2C+12%2C+12%2C+10%2C+9%5D%0A%5B9%2C+9%2C+9%2C+9%2C+11%2C+1%5D%0A%5B8%2C+8%2C+8%2C+8%2C+11%2C+13%5D%0A%5B10%2C+9%2C+3%2C+7%2C+12%2C+2%5D%0A%5B1%2C+2%2C+3%2C+4%2C+5%2C+6%5D%0A%5B10%2C+9%2C+2%2C+3%2C+4%2C+1%5D%0A%5B10%2C+3%2C+12%2C+3%2C+7%2C+12%5D&debug=0).
[Answer]
# Pyth, ~~28~~ ~~27~~ 25 bytes
```
s+*L%/Qd2}3Tm?<d3_d*15q12
```
[Try it online.](https://pyth.herokuapp.com/?code=s%2B*L%25%2FQd2%7D3Tm%3F<d3_d*15q12&input=[4%2C+5%2C+5%2C+3%2C+8%2C+7]&debug=0) [Test suite.](https://pyth.herokuapp.com/?code=s%2B*L%25%2FQd2%7D3Tm%3F<d3_d*15q12&test_suite=1&test_suite_input=[11%2C+10%2C+3%2C+1%2C+2%2C+2]%0A[4%2C+5%2C+5%2C+3%2C+8%2C+7]%0A[2%2C+2%2C+2%2C+2%2C+1%2C+1]%0A[12%2C+12%2C+12%2C+12%2C+10%2C+9]%0A[9%2C+9%2C+9%2C+9%2C+11%2C+1]%0A[8%2C+8%2C+8%2C+8%2C+11%2C+13]%0A[10%2C+9%2C+3%2C+7%2C+12%2C+2]%0A[1%2C+2%2C+3%2C+4%2C+5%2C+6]%0A[10%2C+9%2C+2%2C+3%2C+4%2C+1]%0A[10%2C+3%2C+12%2C+3%2C+7%2C+12]&debug=0)
### Explanation
* Firstly, Pyth auto-appends some variables. The code is now `s+*L%/Qd2}3Tm?<d3_d*15q12dQ`.
* `}3T` generates the list `[3, 4, 5, 6, 7, 8, 9, 10]`.
* Multiply each number in that list (`*L`) by the count of that number in the input (`/Qd`), modulo 2 (`%`…`2`). The result is 0 for paired numbers and the number itself for non-paired ones.
* Map over the input numbers (`m`…`Q`):
	+ If the number is less than 3 (`?<d3`), negate it (`_d`).
	+ Otherwise check if it's 12 (`q12d`), and multiply the boolean by 15 (`*15`). The result is 15 for queens and 0 for anything else.
* Concatenate the lists (`+`). The resulting list now contains the scores for the non-paired numbers (the first part) and the special cards A, 2, Q (the second part), with some extra zeroes.
* Finally, take the sum of the result (`s`).
### Alternative 25-byte solution
```
-+s*L%/Qd2}3T*15/Q12s<#3Q
```
This works similarly to the first one, but counts the queens separately and negates the aces and twos with a filter.
[Answer]
## JavaScript (ES6), 63 bytes
```
a=>a.map(e=>r+=e<3?-e:e>10?e-12?0:15:(m[e]^=1)?e:-e,r=0,m=[])|r
```
Or if you prefer,
```
a=>a.map(e=>r-=e<3?e:e>10?e-12?0:-15:(m[e]^=1)?-e:e,r=0,m=[])|r
```
[Answer]
# [Perl 5](https://www.perl.org/), 74 +1 (`-a`) = 75 bytes
```
map$s+=/12/?15:$_<3?-$_:$_<11?$k{$_}?-delete$k{$_}:($k{$_}=$_):0,@F;say $s
```
[Try it online!](https://tio.run/##K0gtyjH9/z83sUClWNtW39BI397Q1Eol3sbYXlclHsQwNLRXya5Wia@1101JzUktSYXwrDQgtK1KvKaVgY6Dm3VxYqWCSvF/a9VsWw1N6/@GCkYKIAyE//ILSjLz84r/6/qa6hkYGvzXTQQA "Perl 5 – Try It Online")
[Answer]
# [Perl 5.10.0](https://www.perl.org/) + `-n`, ~~115~~ ~~64~~ ~~60~~ 56 bytes
```
$p+=$_-12?$_>2?$_<11?++$l[$_]%2?$_:-$_:0:-$_:15}{say$p
```
[Try it online!](https://tio.run/##K0gtyjH9/1@lQNtWJV7X0MheJd4ORNgYGtpra6vkRKvEx6qCBKx0gdgATBqa1lYXJ1aqFPz/b2jIZWjAZcxlyGXEZfQvv6AkMz@v@L9u3n9dX1M9QwM9AwA)
## Explanation:
Adding the `-n` loop around it:
```
# Used variables:
# $_: input (auto)
# $p: points
# $l[n]: number of occurences of n (for 3-10)
while (<>) { # for every input
    $p += $_ - 12 ? # if the input is not 12 (queen) ...
        $_ > 2 ? # then: if it's > 2 (not ace or 2) ...
            $_ < 11 ? # then: if < 11 (3-10) ...
                ++$l[$_] % 2 ? # then: if it's an odd occurence (1st, 3rd, 5th, ...)
                    $_ # add it
                    : -$_ # else subtract it
            : 0 # no points for other stuff (J, K)
        : -$_ # negative points for ace and 2
    : 15 # 15 points for queen
}
{ # after input:
    say $p # output points
}
```
]