Teaser 3103: Empowered
From The Sunday Times, 13th March 2022 [link] [link]
I have a rectangular garden whose sides are whole numbers of feet. Away from the edge, an exposed strip of ground, again a whole number of feet in width, runs straight across (not diagonally) from a shorter side of the garden to the other shorter side. I need to run an electrical cable along the ground, between two opposite corners of the garden. Where the cable crosses the exposed area, it has to be threaded through expensive linear ducting to avoid damage. Because of costs, whilst seeking to minimise the length of cable, my overriding concern is to minimise the length of ducting used.
The straight-line distance between the two corners to be connected is 123 feet, but in minimising costs, the length of cable needed is a whole number of feet longer than this.
What is the length of cable needed?
[teaser3103]
Jim Randell 4:55 pm on 11 March 2022 Permalink |
The shortest amount of ducting is to cross the exposed area at right angles. The remaining length of cable required is then the diagonal of the garden with the exposed area removed.
This Python program runs in 47ms.
Run: [ @replit ]
from enigma import (pythagorean_triples, irange, ihypot, printf) # look for pythagorean triples with hypotenuse 123 for (x, y, z) in pythagorean_triples(123): if z != 123: continue # consider possible w = width of exposed area for w in irange(1, x - 1): # calculate d = length of cable required d = ihypot(x - w, y) if d is None: continue d += w # output solution printf("x={x} y={y} z={z}; w={w} d={d}")Solution: The total length of cable required is 127 feet.
The garden is an x by y rectangle, where (x, y, 123) form a Pythagorean triple. So:
There is only one possible triple: (27, 120, 123).
Also the width of the exposed area is w (where: w < x).
And the amount of cable required is d we have:
So (x − w, y, d − w) is also a Pythagorean triple.
The only triple with x < 27 and y = 120 is: (22, 120, 122).
Hence:
LikeLike
GeoffR 10:07 am on 12 March 2022 Permalink |
I looked at this teaser as two triangles with one above the horizontal strip and one below the horizontal strip. The cable length was then the sum of the two hypotenuses and the vertical crossing depth of the horizontal strip.
It turns out that the two right angled triangles are the same, with dimensions (11, 60, 61).
LikeLike
Jim Randell 12:17 pm on 12 March 2022 Permalink |
@Geoff: Of course we don’t know that (a, x1, h1) and (b, x2, h2) are all integers. But we do know a+b and h1+h2 must be integers, so we can just consider (a+b, x, h1+h2) to find the solution.
LikeLike
GeoffR 1:28 pm on 12 March 2022 Permalink |
@Jim:
True, but it seemed a reasonable assumption at the time.
The output from the programme verified my assumption, but I understand the technical point you make about these dimensions not being specifically stated as integers.
We do know that the length of the cable(c) is a whole number of feet longer than the diagonal(z), and that c = h1 + w + h2. This suggested to me that it would be perhaps be unlikely for any of h1, w, or h2 to be floating point numbers. My two triangle approach also needs integers to work as Pythagorean triangles, of course.
LikeLike
GeoffR 7:50 am on 14 March 2022 Permalink |
A simpler solution, based on Brian’s manual solution.
LikeLike
Jim Randell 12:56 pm on 14 March 2022 Permalink |
@Geoff: Yes, that is what I was getting at. There is no need to split the garden into two rectangles, when we can just consider the diagonal of the garden with the exposed area removed. (And in the general case, I don’t think it would always be possible to split the remaining garden into two rectangles with integer sides, and with an integer length of cable running through them, so it is lucky that it occurs in this instance).
And we don’t even need to derive a formula for the width of the exposed area.
Here’s my MiniZinc model that interprets my original program:
LikeLike
Hugh+Casement 7:22 am on 21 March 2022 Permalink |
I find that a strange shape for a garden.
A more realistic puzzle would have involved one 140 × 51 ft (diagonal 149 ft),
with a path 3 ft wide, parallel to the long sides, that for practical reasons has to be traversed at right angles to its length.
LikeLike