### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,149)
- misc (2)
- project euler (2)
- puzzle (38)
- site news (44)
- tantalizer (40)
- teaser (3)

### Site Stats

- 175,242 hits

Advertisements

Programming Enigma Puzzles

9 June 2013

Posted by on **From New Scientist #2583, 23rd December 2006**

We have wrapped all this year’s presents in red or gold and placed them in a circle around the Christmas tree. The set of four anticlockwise starting with Joe’s present is gold, red, red, red. The set of four clockwise which starts with Joe’s present finishes with a red one.

In fact, if you name any sequence of four gold/red (e.g. GRGG, RGGR, etc) then there is a set of four consecutive presents which (clockwise, anticlockwise or both) coincides with your sequence. Furthermore, this would not have been possible with fewer presents.

(a) How many presents were round the tree?

(b) Starting with Joe’s and working clockwise, list the colours of the first five presents.

**Enigma 1320** is also called “Around the tree”.

[enigma1423]

Advertisements

%d bloggers like this:

I didn’t think the puzzle was clear about whether all red and all green sequences were allowed (RRRR and GGGG). But if you do allow them you get the required answer.

This Python program runs in 43ms.

Solution:(a) There were 14 presents around the tree; (b) The colours of the first five presents are: green, green, red, red, green.There are two possible sequences for the solution: G G R R G G G G R G R R R R and G G R R G R G G G G R R R R. They differ at the 6th and 9th positions.