Teaser 3123: A six-pipe problem
From The Sunday Times, 31st July 2022 [link] [link]
A factory makes six types of cylindrical pipe, A to F in decreasing size, whose diameters in centimetres are whole numbers, with type A 50 per cent wider than type B. The pipes are stacked in the yard as a touching row of As with an alternating row of touching Bs and Cs in the next layer, with each B touching two As. Type Ds fill the gap between the As and the ground; Es fill the gap between As and the Bs; and Fs fill the gap between As, Ds and the ground. Finally another row of As is put on top of the stack, giving a height of less than 5 metres.
What is the final height of the stack in centimetres?
[teaser3123]

Jim Randell 3:55 pm on 29 July 2022 Permalink |
The title of this puzzle is presumably an allusion to Sherlock Holmes’ “three pipe problem” in The Red-Headed League.
Some judicious applications of Pythogoras’ theorem gets us the answer.
This Python program runs in 54ms. (Internal runtime is 313µs).
Run: [ @replit ]
from enigma import (irange, div, is_square, sq, printf) # suppose the pipes have diameters a, b, c, d, e, f (in cm) # we know h = 2a + c < 500; b = (2/3)a for a in irange(6, 249, step=3): b = div(2 * a, 3) # from pipes ABC c = a - b # calculate the height of the stack (in centimetres) h = 2 * a + c if not (h < 500): break # from pipes AAD: (a + d)^2 = a^2 + (a - d)^2 d = div(a, 4) if d is None: continue # from pipes ABC: (a + e)^2 = (a + c - b - e)^2 + (b + c)^2 e = div(sq(b) + sq(c) - a * (b - c), 2 * a - b + c) if e is None: continue # from pipes ADF: (d + f)^2 = (d - f)^2 + x^2; (a + f)^2 = (a - f)^2 + y^2; x + y = a r = is_square(a * d) if r is None: continue f = div(sq(a), 4 * (a + d + 2 * r)) if f is None: continue if a > b > c > d > e > f > 0: # output solution (in cm) printf("height = {h} cm [a={a} b={b} c={c} d={d} e={e} f={f}]")Solution: The height of the stack is 420 cm.
Note that the derivation of d requires a to also be divisible by 4 (as well as 3), so we could consider just multiples of 12 for a for a slight increase in speed.
Manually:
If we suppose a = 180k, then we can simplify the expressions used in the program to give the following values:
And we require all these values to be positive integers, so k takes on a positive integer value.
The total height of the stack is h = 2a + c = 420k, and we require h < 500.
So the only permissible value is k = 1, and the answer follows directly.
LikeLike
Frits 2:26 pm on 2 August 2022 Permalink |
Problem is when to stop with your analysis.
Ultimately each diameter can be expressed in terms of the smallest diameter.
from enigma import SubstitutedExpression # AGH, BIJ, CK, DL, EM and FN variables are diameters # if (x - y)^2 = z^2 then (2x - 2y)^2 = (2z)^2 # so we can also calculate with diameters in the Pythagorean formulae # the alphametic puzzle p = SubstitutedExpression( [ # type A 50 per cent wider than type B # diameter A is equal to diameter C + two times radius B # a height of less than 5 metres so 2a + c = 7c < 500 "1 < CK < 72", "3 * CK = AGH", "2 * CK = BIJ", # (a + d)^2 = a^2 + (a - d)^2 so 4ad = a^2 "div(AGH, 4) = DL", # (a + e)^2 = (a + c - b - e)^2 + (b + c)^2 using a = 3c and b = 2c # 6ce + 9c^2 = 4c^2 - 4ce + 9c^2 "div(2 * CK, 5) = EM", # (d + f)^2 = (d - f)^2 + x^2; (a + f)^2 = (a - f)^2 + (a - x)^2; # so 4df = x^2 and 4af = (a - x)^2 "4.0 * AGH * FN == (AGH - 2 * (DL * FN)**.5)**2", # A to F in decreasing size "AGH > BIJ > CK > DL > EM > FN" ], answer="2 * AGH + CK, (AGH, BIJ, CK, DL, EM, FN)", d2i=dict([(k, "CF") for k in range(8, 10)]), distinct="", verbose=0, # use 256 to see the generated code ) # print answers for (_, ans) in p.solve(): print(f"the final height of the stack in centimetres: {ans[0]}")LikeLike