### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,183)
- misc (2)
- project euler (2)
- puzzle (46)
- site news (46)
- tantalizer (49)
- teaser (3)

### Site Stats

- 184,820 hits

Advertisements

Programming Enigma Puzzles

25 July 2012

Posted by on **From New Scientist #2875, 28th July 2012** [link]

From a point on one side of a rectangular sheet of paper I drew two straight lines, one of them to a point on one adjacent side and the other to a point on the other adjacent side. My sheet of paper was now divided into two triangles and a pentagon. The lengths of the sides of the triangles were all integers, the lengths of the sides of the pentagon were, in some order, five consecutive integers, each less than 50.

What were the dimensions of the sheet of paper?

**Note:** It might have been clearer if the puzzle talked about the *edges* of the sheet of paper, rather than the *sides* of the corresponding rectangle.

[enigma1708]

Advertisements

%d bloggers like this:

Here’s my first attempt. It runs in 43ms, but I’m not entirely happy with it. I lifted the generator for Pythagorean triples from a Project Euler problem I was looking at.

Here’s a diagram to illustrate how I tackled the problem.

Solution:The dimensions of the sheet of paper are 37 x 66.Here’s a slightly modified approach. It generates all possible Pythagorean triples with a hypotenuse less than 50 up front, and then checks all pairs of them. This does away with the

exit()for termination, and hence checks all possible answers, instead of stopping at the first one. It runs in 37ms.I probably should have done this one in SQL, but here is some Python: