Teaser 2459: [Queue for tea]
From The Sunday Times, 8th November 2009 [link]
At today’s tea break only one of the six workers in the canteen queue actually had tea, the other five having different drinks. Terry was directly behind the one who had hot chocolate, while Tony (who was not at the front of the queue) was immediately in front of the sparkling-water drinker (who was not Terry). The milk drinker was three places in front of the person who had white coffee. Tilly was directly behind Tommy. Timmy was two places ahead of the hot-chocolate drinker. The person at the front of the queue had black coffee.
Who had tea? And where was Trudy in the queue?
This puzzle was originally published with no title.
[teaser2459]
Jim Randell 8:41 am on 6 February 2026 Permalink |
Here is a solution using the [[
SubstitutedExpression]] solver from the enigma.py library.The following run file executes in 79ms. (Internal runtime of the generated code is 87µs).
And here is a Python program that runs the solver, and then formats the output nicely:
from enigma import (SubstitutedExpression, irange, printf) # load the puzzle p = SubstitutedExpression.from_file(["{dir}/teaser2459.run"]) # link names and drinks to symbols names = dict(A='Terry', B='Tony', C='Tilly', D='Tommy', E='Timmy', F='Trudy') drinks = dict(G='tea', H='hot chocolate', I='sparkling water', J='milk', K='white coffee', L='black coffee') # solve the puzzle and format solutions for s in p.solve(verbose=0): # for each position 1-6 fill out a corresponding name and drink name = dict((s[k], v) for (k, v) in names.items()) drink = dict((s[k], v) for (k, v) in drinks.items()) # output the queue for pos in irange(1, 6): printf("{pos}: {n}, {d}", n=name.get(pos, '???'), d=drink.get(pos, '???')) printf()Solution: Terry had tea. Trudy was 6th in the queue.
The positions in the queue and drinks required are:
LikeLike