Teaser 2702: Problemblem
From The Sunday Times, 6th July 2014 [link] [link]
Every Sunday customers in our pub try to solve the current Teaser, so Pat the barman has designed an appropriate pub logo. This is a small rectangular flag divided into three smaller rectangles, coloured red, green and blue. Their sides are all whole numbers of centimetres, the area of the green rectangle is twice the area of the red rectangle, and the perimeter of the red rectangle is twice the perimeter of the green rectangle. Furthermore, the area of the flag is a three-figure number of square centimetres, the same as the area of the blue rectangle but with the three digits in the reverse order.
What is the area of the flag?
[teaser2702]
Jim Randell 10:56 am on 3 January 2023 Permalink |
This Python program generates candidate areas for the red, green and blue rectangles. It then looks for appropriate dimensions that satisfy the remaining conditions, and allow them to fit together as specified.
It runs in 60ms. (Internal runtime is 7.3ms).
Run: [ @replit ]
from enigma import (irange, nrev, div, divisors_pairs, cproduct, ordered, printf) # fit the rectangles (x1, y1), (x2, y2) and a rectangle area A together def fit(x1, y1, x2, y2, A): for z1 in {x1, y1}: # can we match a side? if z1 in {x2, y2}: (x, y) = (z1, div(A, z1)) if y is not None: yield ordered(x, y) # can we join sides? for z2 in {x2, y2}: y = (x1 + y1 - z1) - (x2 + y2 - z2) if y > 0: if z2 * y == A: yield ordered(z2, y) elif y < 0: y = -y if z1 * y == A: yield ordered(z1, y) # consider the area of the flag, it is a 3-digit number for A in irange(100, 999): # and the area of blue is the reverse of this B = nrev(A) if B < 100 or not (B < A): continue # the area of red and green are 1/3 and 2/3 of what is left R = div(A - B, 3) if R is None: continue G = 2 * R # find dimensions for red and green, such that red has twice the perimeter of green for ((rx, ry), (gx, gy)) in cproduct(divisors_pairs(v) for v in (R, G)): if not (rx + ry == 2 * (gx + gy)): continue # find dimensions of blue that fits to make a rectangle for (bx, by) in fit(rx, ry, gx, gy, B): # output solution printf("A={A} [R={R} G={G} B={B}]", R=(rx, ry), G=(gx, gy), B=(bx, by))Solution: The area of the flag is: 231 sq cm.
The flag is a 7×33 rectangle, as shown below:
The red rectangle is: 1×33. The green rectangle is 6×11. The blue rectangle is 6×22.
(Dimensions in cm).
We have sometime come across claims that a phrase such as “a whole number of pounds” (or similar – see Teaser 2869, Teaser 2692) necessarily implies a value must be at least 2 (although I do not accept this argument myself). But this puzzle uses “a whole number of centimetres” to refer to a value of 1, and without allowing this value there would be no solution.
LikeLike
GeoffR 3:28 pm on 3 January 2023 Permalink |
LikeLike