Teaser 3039: Three patterned paving
From The Sunday Times, 20th December 2020 [link] [link]
James is laying foot-square stones in a rectangular block whose short side is less than 25 feet. He divides this area into three rectangles by drawing two parallel lines between the longest sides and into each of these three areas he lays a similar pattern.
The pattern consists of a band or bands of red stones laid concentrically around the outside of the rectangles with the centre filled with white stones. The number of red stone bands is different in each of the rectangles but in each of them the number of white stones used equals the number of outer red stones used.
The total number of stones required for each colour is a triangular number (i.e., one of the form 1+2+3+…).
What is the total area in square feet of the block?
[teaser3039]






Jim Randell 5:51 pm on 18 December 2020 Permalink |
(See also: Teaser 3007).
After some head scratching I realised that the parallel lines are parallel to the short sides of the rectangular block, not the long sides.
Considering a section of paving that is n stones wide and h stones long.
If we count the number of border layers on both sides of the central area, we get an even number b, such that b < n.
And if the border area is the same as the central area we have:
So for any (n, b) pair we can calculate a value for h, and accept values where b < h.
The following Python program runs in 44ms.
Run: [ @replit ]
from enigma import (irange, div, subsets, all_different, is_triangular, printf) # consider values for the short side of the rectangle for n in irange(3, 24): # collect sets of (<section-length>, <border-width>) ss = list() # consider possible border values for b in irange(2, (n - 1) // 2, step=2): # calculate section length h = div(2 * b * (n - b), n - 2 * b) if h is None or not (b < h): continue printf("[n={n} b={b} -> h={h}]") ss.append((h, b)) # choose the 3 sections for ((h1, b1), (h2, b2), (h3, b3)) in subsets(ss, size=3): # the borders are all different if not all_different(b1, b2, b3): continue # total length of the sections h = h1 + h2 + h3 if not (h > n): continue # total number of stones for each colour t = div(n * h, 2) if t is None or not is_triangular(t): continue # output solution printf("{n} x {h} -> A={A} (t={t}); sections = (h={h1}, b={b1}) (h={h2}, b={b2}) (h={h3}, b={b3})", A=2 * t)Solution: The total area of the block is 2352 square feet.
The block is 24 feet wide and 98 feet long, and is split into three sections:
24 feet × 10 feet, border 2 deep. (120 slabs of each colour).
24 feet × 18 feet, border 3 deep. (216 slabs of each colour).
24 feet × 70 feet, border 5 deep. (840 slabs of each colour).
In total 1176 slabs of each colour are required, and 1176 = T(48).
Here’s a diagram of the three sections, with the longest one in the middle:
LikeLike
Frits 6:37 pm on 19 December 2020 Permalink |
I tried pythagorean_triples in combination with SubstitutedExpression (as n^2 + h^2 must be square) but that was too slow.
from enigma import SubstitutedExpression, is_square # number of red stones: (n - b)(h - b) # number of white stones: nh/2 # b^2 - (n + h)b + nh/2 = 0 # the alphametic puzzle p = SubstitutedExpression( [ # AB = number of border layers on both sides of the central area # CDE = long side # FG = short side # FG is at least 15, 2+4+6 = 12, sum 3 different numbers of border layers # plus 3 whites "FG > 14", "FG < 25", "AB * AB - (CDE + FG) * AB + CDE * FG / 2 == 0", "AB > 0", "AB < CDE", "CDE > 0", # IJ = number of border layers on both sides of the central area # KLM = long side "IJ * IJ - (KLM + FG) * IJ + KLM * FG / 2 == 0", "IJ > 0", "KLM > 0", "IJ < KLM", "KLM > CDE", # QR = number of border layers on both sides of the central area # STU = long side "QR * QR - (STU + FG) * QR + STU * FG / 2 == 0", "QR > 0", "STU > 0", "QR < STU", "STU > KLM", # the numbers of border layers are all different "len([AB, IJ, QR]) == len(set([AB, IJ, QR]))", # total number of stones for each colour must be triangular # if t is the nth triangular number, then t = n*(n+1)/2 # and n = (sqrt(8t+1) - 1) / 2 "is_square(4* FG * (CDE + KLM + STU) + 1)" ], answer="FG * (CDE + KLM + STU), FG, CDE, AB, KLM, IJ, STU, QR", # short side is even and < 25 d2i=dict([(0, "F")] + \ [(1, "GBJR")] + \ [(k, "FGBJR") for k in {3, 5, 7, 9}] + \ [(k, "F") for k in {4, 6, 8}]), distinct="", reorder=0, verbose=0) # collect and print answers answs = sorted([y for _, y in p.solve()]) print(" area, n h1 b1 h2 b1 h3 b3") for a in answs: print(f"{a}")LikeLike