From The Sunday Times, 13th October 2024 [link] [link]
Henry learnt snooker scoring basics: pot a red (= 1 pt), not counting as a colour, then a colour (yellow = 2 pt, green = 3 pt, brown = 4 pt, blue = 5 pt, pink = 6 pt, black = 7 pt), alternately. Potted reds stay out of play, while a colour potted immediately after a red returns to play. Once the last red and accompanying colour are potted, then pot the colours in the aforementioned sequence. A miss or foul lets your opponent play.
With fifteen reds available, Henry scored the first points (a prime number) as described, then missed a red with a foul, yielding four points to Ford. Only with these four points could Ford possibly win. Potting all the remaining reds, each followed by colours other than black, then the colours to pink, Ford needed the black to win by one point. He missed with a foul, which ended the game.
Give Ford’s score.
[teaser3238]
Jim Randell 8:41 am on 22 November 2024 Permalink |
We can use the [[
SubstitutedExpression]] solver from the enigma.py library to solve this puzzle.The following run file executes in 79ms. (Internal runtime of the generated program is 330µs).
Solution: HUIT = 4539.
We have:
LikeLike
Frits 4:28 am on 23 November 2024 Permalink |
@Jim, your first run members had option -r on line 1 but the newer ones have option -rr.
Can you explain the difference as I have problems finding it in enigma.py.
LikeLike
Jim Randell 10:09 am on 23 November 2024 Permalink |
The
-roption is short for the--runoption, which also allows you to specify the type of the file to run.The following additional arguments are accepted by the
--runoption:If the type is not specified then it is set from the file extension. But specifying the type as an argument allows the code to run correctly, even if it is saved to a file that does not have a
.runextension.LikeLike
Ruud 8:06 am on 23 November 2024 Permalink |
Very brute force
import istr for t, w, o, f, u, r, e, h, v, i in istr.permutations(range(10), 10): if ( (t | w | o) + (t | w | o) == (f | o | u | r) and (f | i | v | e).is_prime() and ((f | i | v | e) - (t | w | o)).is_prime() and (t | h | r | e | e).is_divisible_by(3) and t * f * h ): print(f"two={t|w|o} four={f|o|u|r} five={f|i|v|e} three={t|h|r|e|e} huit={h|u|i|t}")LikeLike
Frits 12:49 pm on 23 November 2024 Permalink |
@Ruud, I thought you had forgotten about the non-zero first characters but it is there at line 9.
The istr concatenation character might become aesthetically problematic when there is a letter L. In that case would you use upper case variables?
LikeLike
Ruud 4:21 pm on 23 November 2024 Permalink |
In contrast to most contributors here, I try and follow PEP8 conventions, which implies lowercase variables.
LikeLike