by Susan Denham

From New Scientist #1751, 12th January 1991

In snooker there are 15 red balls worth one point each. If a player pots a red it stays in the hole and he (or she) is allowed to try to pot one of the colours yellow, green, brown, blue, pink or black (worth 2-7 points in that order). If a colour is potted it is brought out again and the player can try for another red, and so on. This continues until all the reds have gone. Then the remaining six colours are potted in ascending order.

The total points achieved in one such run is called a “break”. For example:

red + pink + red + black + red

would be a break of 16.

Having completed the break, the player sits down and lets the other player try for a red and continue the break, and so on. At the end the winning player is the one with the higher grand total of points. A player may choose not to pot the final black if the result is already determined without it. No other rules concern today’s story.

Stephens and Hendry play a frame of snooker. Stephens starts with a break of 3, Hendry follows with a break of 4, Stephens with a break of 5, and so on, and this pattern continues to the end. As usual in quality snooker, the black was potted more times than the yellow, and the pink was potted more times that the blue.

How many times did Stephens pot the brown? And how many times did Hendry pot the brown?

From → Uncategorized

I had problems finding the solution for this one because I missed the possibility that the last break involving reds could end in two non-reds, the last being a yellow.

This runs in 220 milliseconds. Although this is much faster than Jim Randell’s original version, I like the elegance of Jim’s version so I have produced another version following his approach:

NOTE: This code originally had a bug which has now been corrected (see Jim’s comment below).

Using profile based timing and CPython version 3.9 with Jim’s multiset implementation, this now gives a run-time of 1.9 seconds, which compares with 2.05 seconds for Jim’s original version. Switching to the Pypi multiset implementation reduces the run-time to 1.1 seconds, a significant performance gain.

2. @Brian: I think your second program doesn’t generate all viable sequences, which might explain the run time. For example it doesn’t seem to allow breaks where the same colour is potted more than once. When I corrected this I found that the program was slower than my code.

I have since adapted my original program into a faster version that can also be used to solve Enigma 598 [ https://enigmaticcode.wordpress.com/2021/01/01/enigma-598-break-down/ ]. It solves this puzzle in 240ms.

The adapted version is available here [ https://enigmaticcode.wordpress.com/2020/12/28/enigma-597-break-uprithmetic/#comment-10353 ].