Sunday Times Teaser 2968 – Gardening Division
by Danny Roth
Published August 11 2019 (link)
George and Martha’s garden is a perfect square of length (whole number of metres) a twodigit number ab. The area is a threedigit number cde. In the middle, they have planted a square flowerbed of a length which is a singledigit number f and area a twodigit number gh.
They have called in a gardener, who works for a singledigit i hours. He works for a whole number of minutes on the flowerbed and the remainder on the surrounding lawn. Each square metre of the flowerbed requires n (a single digit) times the time spent on each square metre of the surrounding lawn. I have mentioned nine letters, ai inclusive, and each stands for a different positive digit.
How many minutes does the gardener work on the lawn?

Brian Gladman permalink123456789101112131415161718192021222324252627# square garden of side AB, area CDEfor AB in range(10, 32):A, B = divmod(AB, 10)CDE = AB ** 2C, D, E = (int(x) for x in str(CDE))# digits A, B, C, D and E in 1..9 and all differents4 = set(range(1, 10)).difference([A, B, C, D, E])if len(s4) != 4:continue# square flower bed of side F, area GHfor F in s4.difference([1, 2, 3]):GH = F ** 2G, H = (int(x) for x in str(GH))# gardener works I hoursI, *r = s4.difference([F, G, H])if r:continueprint(f"A={A}, B={B}, C={C}, D={D}, E={E}, F={F}, G={G}, H={H}, I={I}")# lawn_min = [(cde  gh) / (cde  gh + n.gh)].(60.i) for some N in 1..9for nm1 in range(9):lawn_min, r = divmod(60 * I * (CDE  GH), CDE + nm1 * GH)if not r:print(f"The gardener works {lawn_min} (of {60 * I}) minutes on the lawn.")

Erling Torkildsen permalink12345678910111213141516171819202122232425from itertools import permutationsZ = set('123456789')for a in range(1, 4):for b in range(1, 10):if b == a:continueA, B = str(a), str(b)cde = (10 * a + b) ** 2CDE = str(cde)if A not in CDE and B not in CDE:if len(CDE) == len(set(CDE)) == 3:FGHI = Z.difference(set((CDE + A + B)))for F, G, H, I in permutations(FGHI):f, g, h, i = int(F), int(G), int(H), int(I)if f ** 2 == 10 * g + h:bed, lawn = f ** 2, cde  f ** 2for n in range(2, 10):v = 60 * i / (bed * n + lawn)if bed * n * v == int(bed * n * v):print(f"({cde}  {bed})m2", end="")print(f" * {v} min/m2", end="")print(f" = {int(lawn * v)} min.")