# Enigmatic Code

Programming Enigma Puzzles

## Enigma 347: Trellis

From New Scientist #1496, 20th February 1986 [link]

I went out on Tuesday to buy a piece of trellis to cover a gap which I measured 30 inches wide × 48 inches high. Allowing half an inch spare on all sides for fixing, I needed at least 31 inches × 49 inches.

I found at the shop that they sold the stuff in various sizes. Size 5, for instance, which is shown in the picture, has five rows of five studs (on which the whole thing swivels); size 6 has six rows of six studs and so on.

In every size the studs were 5 inches apart along the slats, which were 1 inch wide, with each end rounded off in a semicircle of ½-inch radius centred on the last stud.

When I told the manager my measurements, he said,” I’m afraid size 11 will be just too small. If you pull it out to 31 inches wide, the height will be just short of 49 inches. So you’d better take size 12. We charge 5p per stud, so that will be £7.20… Yes, certainly we’ll change it if the size should be wrong.”

When I got home, I was horrified to find that I had mis-measured the height of the gap. It was really 84 inches, not 48 inches. So I needed 31 inches × 85 inches. Back I went to the shop, where, having done my homework meanwhile, I was able this time to ask myself for the size most economical of trellis that would meet my requirements exactly.

What was the price of this trellis?

[enigma347]

### One response to “Enigma 347: Trellis”

1. Jim Randell 3 June 2016 at 8:41 am

I think there is something a little suspect about this puzzle.

This program explores the dimensions a trellis can be stretched to when used either horizontally or vertically. It runs in 39ms.

from itertools import count
from enigma import sqrt, irange, printf

# return height for a size <n> trellis stretched to width <w>
def trellis(n, w):
# how many diamonds wide and high is the trellis
(dh, dw) = ((0.5 * (n - 1)), 0.5 * (2 * n - 1))
# so each diamond must be this wide...
x = w / dw
try:
# ... and this high
y = sqrt(100.0 - x * x)
# so the total height is...
return y * dh
except ValueError:
return None

# find the best trellis for a dimension of w x h
def best(w, h):
for n in count(3):
x = trellis(n, w)
if x is None or not(x > 0.0): continue
p = n * n * 5
printf("size {n}, price={p}p: width={w} height={x}")
if not(x < h):
printf()
break

# consider both orientations
for rotate in (0, 1):
# try both sets of dimensions
for (i, (w, h)) in enumerate([(30, 48), (30, 84)]):
if rotate: (w, h) = (h, w)
printf("[width={w}, height={h}]")
best(w, h)

If we have a size 11 trellis and stretch it to 30″ wide, then it does just fall short of 48″ high. (It is actually 47.916″ high).

And if we take a size 12 trellis and stretch it to 30″ wide, then it is over 48″ high. (It is actually 53.096″ high).

But to achieve a height of 84″, a size 18 trellis falls just short at 83.742″. But a size 19 trellis stretched to 30″ wide achieves a height of 88.809″.

However, if we are allowed to rotate the trellis, we find we can use a smaller size trellis. This is the equivalent of rotating the gap.

So if we look at a gap that is 84″ wide and 30″ high, we find we can use a size 11 trellis to fit over the gap exactly (and looks much more pleasing than the size 19 trellis).

And this is given as the published solution.

Solution: A size 11 trellis will exactly fill the gap. The prices of the trellis is £6.05.

But if that’s the case, when we were initially considering a 30″ × 48″ gap we could stretch a size 9 trellis to 48″ wide and it would cover a gap of height 33.012″, so we wouldn’t have needed the size 12 trellis in the first place.

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