Teaser 2426: [Magic squares]
From The Sunday Times, 22nd March 2009 [link]
My grandson has learnt about 3 × 3 Magic Squares (tables of nine different positive whole numbers with each row of three, column of three and diagonal of three adding to the same sum). To illustrate, he placed 100 in the centre of a 3 × 3 table and 1 somewhere else in the table.
He asked me to choose any other number lower than 200 and said he would place it in the table and complete it to make a Magic Square.
This would have been possible for most numbers, but I unkindly chose my age, knowing the task would then be impossible.
How old am I?
This puzzle was originally published with no title.
This completes the archive of Teaser puzzles from 2009. There is now a complete archive of Teaser puzzles from January 2009 to the most recent puzzle published in July 2026 (this represents 916 puzzles), as well as 454 earlier Teaser puzzles.
[teaser2426]
Jim Randell 9:08 am on 24 July 2026 Permalink |
Here is a solution using the [[
SubstitutedExpression()]] solver from the enigma.py library.It runs in 108ms. (Internal runtime is 34ms).
from enigma import (SubstitutedExpression, irange, union, diff, seq2str, printf) # A B C # D E F # G H I # possible numbers in the grid N = 199 digits = irange(1, N) # we have E = 100 # 1 is either placed in a corner (A) or edge (B) # magic constant is 3E = 300 eqs = [ "A + B + C == 300", # row 1 "D + E + F == 300", # row 2 "G + H + I == 300", # row 3 "A + D + G == 300", # col 1 "B + E + H == 300", # col 2 "C + F + I == 300", # col 3 "A + E + I == 300", # diag 1 "C + E + G == 300", # diag 2 ] # consider placing 1 at A or B for q in "AB": # make a puzzle for this magic square p = SubstitutedExpression( eqs, base=N + 1, digits=digits, s2d={ 'E': 100, q: 1 }, verbose='', ) # collect all numbers that can appear in the square ns = union(s.values() for s in p.solve()) # most numbers should be possible if not (2 * len(ns) > N - 2): continue # output impossible numbers xs = diff(digits, ns) printf("{q}=1 -> impossible = {xs}", xs=seq2str(xs)) printf()The 1 must be placed in an edge cell (i.e. not a corner cell), and then the following numbers cannot appear in a square:
(Note that these form two pairs (34, 166) and (67, 133), each with a sum of 200).
The most likely of these to be the age of someone who has a grandson interested in magic squares (so, maybe aged around 10), is 67.
Solution: The setter is 67.
LikeLike
Frits 5:11 pm on 25 July 2026 Permalink |
# A B C # D E F # G H I # assume A = 1 or B = 1 # A = 1 is invalid as it causes both C < 100 and G < 100 and C+E+G < 300 # B = 1 leads to # A 1 299 - A # 399-2A 100 2A - 199 # A - 99 199 200 - A used = set() for a in range(101, 199): ns = {a, 1, 299 - a, 399 - 2 * a, 100, 2 * a - 199, a - 99, 199, 200 - a} # nine different positive whole numbers if len(ns) == 9: used |= ns print(f"answer: {''.join(str(n) for n in range(45, 100) if n not in used)}")LikeLike