### by Howard Williams

#### Published Sunday May 21 2023 (link)

My new craft project involves card folding and requires a certain amount of precision and dexterity. For the penultimate stage a rectangular piece of card, with sides a whole number of centimetres (each less than 50cm), is carefully folded so that one corner coincides with that diagonally opposite to it. The resulting five-sided polygon also has sides of integer lengths in cm. The perimeter of the polygon is five twenty-eighths smaller than that of the perimeter of the original rectangular card.

As a final check I need to find the new area of the card.

What, in square centimetres, is the area of the polygon?

From → Uncategorized

Here is the layout used in the program below:

The rectangle has sides of length a and b and its diagonal is of length c; the fold line, which crosses the diagonal at its mid-point and is perpendicular to it, is of length d. The relationships between the various lengths can be derived using similar triangles. Since the fold line has an integer length, we know that the diagonal must be rational which means that (a, b, c) a Pythagorean triple.

I ended up with more or less the same program as Brian.

Jim Randell already has used Pythagorean triples. Luckily I found a different approach (divisors).

@Brian, when I use (without even calling divisors()):

the program runs considerably slower . This doesn’t happen when I import divisors from enigma.

@Frits, I believe Jim optimes factors and divisors in enigma for small values, whereas I optimise for large values by caching primes on import.

I asked ChatGPT to write the Python code to solve this Teaser. What it produced does not work. As a curiosity, here it is:

Hi John, I have also tried this on some of the teasers with variable success. After seeing your attempt I tried to guide it to a correct solution by suggesting what was wrong with its efforts. I gave up after several attempts, none even close to being correct.

BLTN
#returns the integer square root of x if x is a perfect square, else False
squif = lambda x : y if x == (y := int(x ** 0.5)) ** 2 else False

for a in range(1, 50): # height of rectangle
for b in range(1, 50 – a): # fold position

# c is diagonal of rectangle (a, b); d = length of fold, must be integers
if ((c := squif(a * a + b * b)) and
(d := squif((a * a) + (c – b) ** 2)) and
(2 * (a + b) + d) * 14 == (a + b + c) * 23):

print(‘Rectangle h:’, a, ‘w:’, b + c, ‘fold length:’, d)
print(“area”, a * (c + b + b) // 2 )