I was watching the world snooker championship and it got me wondering..
Snooker scoring
In the game of snooker there are certain rules that you must adhere too:
- When there are red balls on the table, during your turn you must first pot a red ball
- After potting each red ball, you must pot a colored (not red) ball (the potted colored ball is then replaced onto the table)
- After all the red balls are up (there are 15) you can first choose a colored ball and then you start with the lowest scoring ball and work your way up to the highest scoring ball (these are not replaced)
- Not potting at any point ends your turn.
- Points per ball
- Red ball: 1 point
- Yellow ball: 2 points
- Green ball: 3 points
- Brown ball: 4 points
- Blue ball: 5 points
- Pink ball: 6 points
- Black ball: 7 points
The question
You start with a table with all the balls still on it - 15 red and one of each of the other coloured balls - and are given the score of a player in snooker after their first turn, what are the ways that they could have achieved this score?
Input will be a score going from 1 to 147. You can choose if it is an integer or a string. Output should be the different combinations of number of times you potted each ball.
Test cases:
Input: 4
Output:
1r 1g
2r 1y
Input: 25
Output:
4r 3b
5r 2b 1br 1y
5r 2b 2g
...
9r 8y
Rules:
- You can choose whether you output the possibilities divided by a new line or a separator of some sort (/,;|\ or even others I'm missing)
This is codegolf, so the shortest code wins.
"5r 3b 2g"
could be output as[5,0,2,0,3,0,0]
(as long as this is consistent)? \$\endgroup\$b
for brown andbl
for blue; sobk
for black? Could we usen
,e
andk
(last letters) for these three? How aboutdleruna
to identify all eight colours (3rd letter of each)? \$\endgroup\$