Teaser 3024: Triple jump
From The Sunday Times, 6th September 2020 [link]
From a set of playing cards, Tessa took 24 cards consisting of three each of the aces, twos, threes, and so on up to the eights. She placed the cards face up in single row and decided to arrange them such that the three twos were each separated by two cards, the threes were separated by three cards and so forth up to and including the eights, duly separated by eight cards. The three aces were numbered with a one and were each separated by nine cards. Counting from the left, the seventh card in the row was a seven.
In left to right order, what were the numbers on the first six cards?
[teaser3024]
Jim Randell 5:03 pm on 4 September 2020 Permalink |
(See also: Enigma 369).
I assume that for each set of three cards with value n (the aces have a value of 9): the leftmost one is separated from the middle one by n other cards, and the middle one is separated from the rightmost one by n other cards. (So the leftmost and rightmost instances are not separated by n cards).
I treat the puzzle as if cards with values 2 to 9 were used (3 copies of each). Then when we have found a solution we can replace the value 9 cards with aces.
This Python program runs in 50ms.
Run: [ @repl.it ]
Solution: The first 6 cards are: 1, 2, 6, 8, 2, 5.
Without pre-placing the 7’s there are four sequences that work (or two sequences, and their reverses):
The answer to the puzzle is the first of these sequences.
LikeLike
Jim Randell 11:15 am on 5 September 2020 Permalink |
Here is a MiniZinc model to solve the puzzle:
LikeLike
Jim Randell 4:32 pm on 5 September 2020 Permalink |
And here’s an alternative implementation in Python that collects the indices of the central cards of each value, rather than filling out the slots:
LikeLike
Frits 8:57 pm on 5 September 2020 Permalink |
Based on Jim’s MiniZinc model.
Only the last”v” call is necessary, the rest is added for performance., it’s a bit messy.
LikeLike