I think everyone is familiar with darts, some people dont understand the scores so for those people here is a usefull link on that.
A dartboard can be compared to a pie cut in 20 pieces. Each piece is divided in 4 sections.
- a small outer ring called double (points x2)
- a big ring called single (points x1)
- another small ring called triple (points x3)
- another big ring called single (points x1)
In the middle of the board are 2 more rings, a green and red one (classic board)
- Red ring, center of the board called bullseye or double bull and is good for 50 points. This one counts as a double and because of that its allowed to checkout with it.
- Green ring, called bull, single bull or simply 25 and counts as a single.
Find all checkout possibilties with 3 darts or less.
The user can enter an integer and you will have to check if its possible to get the score to 0 with 3 darts (or fewer).
Input: 170 Output: T20, T20, Bullseye
Input: 6 Output: D3; S3,S1,D1; S2,D2; S2,S2,D1; D2,D1; S4,D1; D1,D1,D1; S1,S1,D2; T1,S1,D1;
Input: 169 Output: No possible checkout!
- Basic dart rule, you must end with a double (outer ring of the board or bullseye)
- No use of external resources.
- Hard coding of possible checkouts is allowed but remember this is codegolf, it wont get your code short ;)
- Cells to hit will be displayed in format C+N where C = T for Triple, D for double and S for single.
- bullseye can be called bullseye or DB, DBull or something simular.
To get you started, The highest possible checkout is 170.
169,168,166,165,163,162,159 are not possible in 3 darts.
The lowest possible checkout is 2.
This isnt a requirement, add in a possibility to show all possible checkouts for all scores. Basicly because I wonder how many combinations are possible :P
Winner will be the one with the shortest code.