### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,114)
- misc (2)
- project euler (2)
- puzzle (29)
- site news (43)
- tantalizer (29)
- teaser (3)

### Site Stats

- 166,224 hits

Programming Enigma Puzzles

1 October 2012

Posted by on **From New Scientist #2673, 13th September 2008**

Many years ago, Joe made a 3-foot-wide path from his back door to his garden shed using whole 2-foot by 1-foot paving slabs. Viewed from his back door, he wanted to ensure that the pattern of slabs in any 2- foot-long section of the path was not duplicated.

This limited the length of the path, so he had to move his shed a little nearer to the house!

How long was Joe’s path?

[enigma1511]

Advertisements

%d bloggers like this:

This was a fun puzzle to solve. Here is a recursive Python program that enumerates all possible paths and determines the maximum length. It runs in 83ms.

Solution:The path is 14 ft long.Jim, thanks for telling me about pre and /pre. One fine day I’m going to teach myself HTML.

Even so, it’s hard to draw diagrams with text characters, and I’m not confident that Word tables with judiciously merged cells will come across unscathed, so I can’t show you what my tentative 14-foot path looks like. Are you prepared to draw yours for us? Or are there many possible patterns?

These days the slabs measure 30 cm. Hence the “many years ago”. But one probably uses a quarter inch or so of grouting between them, so the path is still near enough 3 feet wide!

My program finds 96 paths of length 14.

Here’s an example of one of them (for anything sufficiently complicated I tend to upload an image):

In each square (a slab covers two squares) the slab crosses one edge of the square, leaving grey around the other three edges. We can label each square by what the grey area looks like, as they look a bit like stylised letters: N where the slab crosses the bottom edge of the square, U where the slab crosses the top edge of the square, C where the slab crosses the right edge of the square and D where the slab crosses the left edge of the square. (In my program I labelled these N, S, W and E).

The path above corresponds to:

Taking adjacent pairs we get:

None of which repeat, so they form different patterns. And this path cannot be extended further without causing a repeating pattern.

Many thanks, Jim. If you look where the gap between slabs runs right across the path, we have five blocks, alternately two and four slabs long. I found those, but wasn’t sure whether the order I had them in really constituted different patterns. I’s now a bit clearer to me.