# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1011: The ribbon’s reach

From New Scientist #2165, 19th December 1998 [link]

Mary is wrapping her last Christmas present, which is a rectangular box which measures 1 metre by 1 metre by 2 metres. She has attached one end of a piece of ribbon to a corner of the box. Amazingly, she finds that the ribbon is just long enough to reach any point on the surface of the box; however if it were any shorter it would not be able to do that.

How long, to the nearest millimetre, is the ribbon?

[enigma1011]

### One response to “Enigma 1011: The ribbon’s reach”

1. Jim Randell 10 May 2019 at 9:09 am

We are being asked what is the furthest point from a vertex on a 1×1×2 brick, and how far is it?

If we place the brick on one of the 1×1 faces, ABCD, and label the top face A’B’C’D’, so that the vertical edges are AA’, BB’, CC’, DD’, then we can consider finding the furthest point from A.

We initially might suppose that the furthest point is the opposite vertex, C’.

To get there can travel along an edge of length 2 (AA’), and then across a 1×1 face (A’C’) to give a total distance of (2 + √2) = 3.414…

But this is not the shortest path. If you’ve come across this kind of “spider and fly” problem before you will have come across the technique of flattening the brick and drawing a straight line across the flattened net to find a shortest path.

We can flatten the top and find that, crossing two faces (ABB’A’ and A’B’C’D’), we can achieve a distance of hypot(1, 3) = 3.162…

But this is still not the shortest distance to this point.

If we fold out the side we find that, we can cross two of the oblong faces (ABB’A’ and BCC’B’) and get a distance of hypot(2, 2) = 2.828…

But it turns out that the opposite vertex is not the most distant point after all.

If we consider points on the top face, then we see that points on the diagonal A’C’ are at a maximal distance for any point approached by a straight line in one of the diagrams given below.

(For points below the line we can find a point that is further, and for points above the line they are at the same distance as the mirror point below the line).

So let’s consider points that at a horizontal and vertical distance x from the vertex C’.

For paths on the left diagram we get a distance of:

y = hypot(1 – x, 3 – x)

which is the blue curve in the graph below.

For paths on the right diagram we get a distance of:

y = hypot(2 – x, 2 + x)

which is the red curve in the graph below.

We see that most of the time the blue line gives a shorter distance, but there is a portion of the graph for small values of x where the red line distance is shorter than the blue line distance.

And the maximum possible distance occurs when the lines cross (and the distance is the same along either path).

The distances are the same when:

(2 – x)² + (2 + x)² = (1 – x)² + (3 – x)²
8 + 2x² = 10 – 8x + 2x²
8x = 2
x = 1/4

And in this case the distance is √(65/8) = 2.850…

Solution: The ribbon is 2850 mm long.

And here is a Python program to find the maximum distance:

Run: [ @repl.it ]

```from enigma import find_max, hypot, fdiv, printf

fn = lambda x: min(hypot(1 - x, 3 - x), hypot(2 - x, 2 + x))

r = find_max(fn, 0, fdiv(2, 3))

printf("max distance = {r.fv:.3f}")
```

If we perform the same trick with antipodal points on the diagonals AC and A’C’, we find the blue and red distances are:

y = hypot(1 – 2x, 3)
y = hypot(2 – 2x, 2 + 2x)

and these intersect at:

x = (–1 + √3) / 2

giving a maximal distance between two points on the brick of:

y = 2√(4 – √3) = 3.012…

This site uses Akismet to reduce spam. Learn how your comment data is processed.