Sunday Times Teaser 3161 – Going Through the Hoops
Published Sunday April 23 2023 (link)
I arrived very late to watch the croquet game. Someone had listed the times when the four balls (blue, black, red and yellow) had run through hoops 1 to 12; none had yet hit the central peg to finish. Blue had run each hoop earlier than black, and every hoop had been run by colours in a different order. The only change in running order from one hoop to the next-numbered hoop was that two colours swapped positions. These swapping pairs (to obtain the order for the next-numbered hoop) were in non-adjacent positions for hoops 5 and 10, but no others. For one particular colour, all the hoops where it passed through earlier than the yellow were before all those where it passed through later than the yellow.
In what order had the balls run the twelfth hoop?
@Brian, nice solution.
Can you elaborate on the benefits of the new WordPress site?
The only change I see is a new font for the Python code. I hoped with every comment we could see a creation timestamp.
It was intended to be a cost reduction but it was a disaster since the promised
site migration didn’t work. So I am now back to my old host. I had to do some
recovery work and this meant that my Python formatting plug-in has changed. I
can set the font but I left it on default – is it better or worse? EDIT: I put
it back to the old font.
I like the old font better, thanks.
The teaser is ambiguous about which hoop to hoop transitions have non adjacent swaps. A single solution is reached for transitions from 5 to 6 and 10 to 11.
Line 26 can be written more efficiently as:
A more compact version of my first post
My definitive version:
Variables byt, ayt and cc could be made ‘global’ in hp (if cc is removed from the argument list and from the ‘yield’) which would result in improved run time but would this be considered good style?
Never say never; tighter still