Teaser 2365: [Madison’s square garden]
From The Sunday Times, 20th January 2008 [link]
Madison has a square front garden with sides a whole number of metres long. It contains a square lawn with sides a whole number of metres long. The rest of the garden consists of a border that Madison wishes to treat with fertiliser before planting.
To work out the area to be treated, Madison has written down the area of the garden, the area of the lawn and the difference between the two. These three numbers between them use each of the digits 0 to 9 exactly once.
What, in square metres, is the area of the border?
This puzzle was originally published with no title.
So I have changed the name to facilitate a weak pun.
[teaser2365]





Jim Randell 4:55 pm on 4 September 2026 Permalink |
This Python program collects increasing square numbers with distinct digits, and attempts to pair each one up with a smaller such square, so that the digits of the squares and the difference give 10 different distinct digits between them.
It runs in 73ms. (Internal runtime is 2.8ms).
from enigma import (irange, inf, seq_is_distinct, printf) digits = str # convert integer to digits (could use enigma.nsplit) # record squares without repeating digits sqs = list() for n in irange(1, inf): sq1 = n * n ds1 = digits(sq1) if len(ds1) > 5: break if not seq_is_distinct(ds1): continue # look for a smaller square to go with this one for (sq2, ds2) in sqs: d = sq1 - sq2 ds = ds1 + ds2 + digits(d) if len(ds) == 10 and seq_is_distinct(ds): # output solution printf("{sq1} - {sq2} = {d}") # add this (<square>, <digits>) sqs.append((sq1, ds1))Solution: The area of the border is 765 sq m.
The garden has area 1089 (= 33²) sq m, and the lawn has area 324 (= 18²) sq m.
LikeLike
Ruud van der Ham 6:29 pm on 4 September 2026 Permalink |
print( *[ (a1, a2, a3) for l1 in range(1, 100) for l2 in range(1, l1) if "".join(sorted(str(a1 := l1 * l1) + str(a2 := l2 * l2) + str(a3 := l1 * l1 - l2 * l2))) == "0123456789" ] )LikeLike
Frits 10:58 am on 5 September 2026 Permalink |
flat = lambda group: [x for g in group for x in g] # 4-digit squares with different digits sqs3 = [(n * n, s) for n in range(31, 9, -1) if len(set(s := str(n * n))) == 3] # 4-digit squares with different digits sqs4 = [(n * n, s) for n in range(32, 100) if len(set(s := str(n * n))) == 4] # check if three strings all have different digits with length 10 def check(*s): t = flat(s) return len(t) == 10 and len(set(t)) == 10 # 5-4-1 is impossible with different digits # check if 4-4-2 is possible for i, (n1, ds1) in enumerate(sqs4): for n2, ds2 in sqs4[:i][::-1]: if n1 - n2 >= 100: break if not check(ds1, ds2, str(n1 - n2)): continue print(f"answer: {n1 - n2} square meters") # check if 4-3-3 is possible for n1, ds1 in sqs4: if n1 > 1839: break # 975 + 864 for n2, ds2 in sqs3: if n1 - n2 >= 1000: break if not check(ds1, ds2, str(n1 - n2)): continue print(f"answer: {n1 - n2} square meters")LikeLike