Teaser 2331: Everyone’s invited
From The Sunday Times, 27th May 2007 [link]
The letters A, B, C, D, E, F, G, H and I stand for the digits 1 to 9 in some order. Thus AB, CD and EF are two-digit numbers; [and] GHI is a three-digit number. George and Martha arranged a big wedding for their granddaughter. The top table consisted of AB members (fewer than 60) of their extended family. There were CD other tables each seating EF guests. The total attendance was GHI (fewer than 500).
What was the total attendance?
[teaser2331]




Jim Randell 8:34 am on 30 January 2026 Permalink |
Here is a solution using the [[
SubstitutedExpression]] solver from the enigma.py library.It runs in 92ms. (Internal runtime of the generated code is 14.8ms).
Solution: The total attendance was 489.
The top table seated 57.
And then there were either 12 additional tables, each seating 36; or 36 additional tables, each seating 12.
The total attendance is thus: 57 + 12 × 36 = 489.
LikeLike
ruudvanderham 9:46 am on 30 January 2026 Permalink |
import peek import istr for A, B, C, D, E, F, G, H, I in istr.permutations(range(1, 10)): if A <= 5 and G <= 4 and (A | B) + (C | D) * (E | F) == (G | H | I): peek((A | B), (C | D), (E | F), (G | H | I))LikeLike
GeoffR 5:52 pm on 30 January 2026 Permalink |
from itertools import permutations dgts = set('123456789') for p1 in permutations(dgts, 2): A, B = p1 AB = int(A + B) if AB < 60: q1 = dgts.difference({A, B}) for p2 in permutations(q1): C, D, E, F, G, H, I = p2 CD, EF = int(C + D), int(E + F) GHI = int(G + H + I) if GHI == AB + CD * EF: if GHI < 500: print(f"Total attendance = {GHI}") # Total attendance = 489LikeLike