I think everyone is familiar with the game of darts. For those that don't understand the scores, here is a useful link.
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 one and red one (classic board)
- Red ring, at the center of the board, is called "bullseye" or "double bull" and is good for 50 points. This one counts as a double and because of that it's allowed to checkout with it.
- Green ring is called "bull", "single bull", or simply "25" and counts as a single.
Find all checkout possibilities with 3 darts or less.
The user can enter an integer and you will have to check if it's 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 rules, 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 won't 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 similar.
To get you started, the highest possible checkout is 170.
169, 168, 166, 165, 163, 162, and 159 are not possible in 3 darts.
The lowest possible checkout is 2.
This isn't a requirement: add in a possibility to show all possible checkouts for all scores. Basically because I wonder how many combinations are possible :P
Winner will be the one with the shortest code.