### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,367)
- misc (4)
- project euler (2)
- puzzle (90)
- puzzle# (48)
- site news (58)
- tantalizer (94)
- teaser (7)

### Site Stats

- 233,129 hits

Programming Enigma Puzzles

19 March 2013

Posted by on **From New Scientist #2610, 30th June 2007**

I wrote six non-zero consecutive digits on separate cards and gave two cards each to ‘Arry, Barry and Carrie. Each of them used their two digits to form a two-figure number, and then they multiplied together the three two-figure numbers.

When I asked them what the answer was they simply spelled it out by placing the six cards in a particular order.

With a little threesome logic – and far fewer multiplications than you might expect – it is possible to work out what their three two-figure numbers were.

What, in increasing order, were they?

[enigma1449]

%d bloggers like this:

This Python program runs in 42ms.

I’ve included a generic function called [[

`partitions()`

]] which generates partitions of a sequence into n-tuples. It’s used here to assign the cards in pairs amongst the three recipients. It could have similarly been used inEnigma 70to generate the possible pairings of brothers. As it has general utility I shall incorporate it into theenigma.pylibrary of useful routines.Solution:The three numbers are 56, 87 and 94.The text of the puzzle implies that such an exhaustive search is not the preferred solution, so here’s an analytical approach.

There are four possible sequences of 6 consecutive digits: 123456, 234567, 345678 and 456789.

Consider 123456. Any product made from a rearrangement of these digits will have a digital root of 3, and so has exactly one factor of 3. Hence exactly one of the 2-digit numbers is divisible by 3, and it has exactly one factor of three.

If we consider the 2-digit numbers x < y < z, then z ≤ 65, y ≤ 54, x ≤ 43, and their product p ≥ 123456, hence x ≥ 123456 / (65 x 54), so x ≥ 36.

So considering possible values for 36 ≤ x ≤ 43, and corresponding y, z and (where necessary) p, factors of 3 are marked with *:

So we can eliminate the first case having only performed 2 calculations for p.

Now consider 234567. The digital root is 9, so any p is divisible by 9, so there are exactly two factors of 3 in x, y and z.

Also z ≤ 76, y ≤ 65, 52 ≤ x ≤ 54.

So:

So the second case is also eliminated with only 2 calculations for p.

Considering 345678. The digital root is 6, so there is only one factor of 3 among x, y and z.

Also z ≤ 87, y ≤ 76, 53 ≤ x ≤ 65.

So:

The third case is eliminated with 6 calculations for p.

Considering 456789. The digital root is 3, so there is a single factor of 3 among x, y, z.

Also z ≤ 98, y ≤ 87, 54 ≤ x ≤ 76.

So:

In this case the unique solution is found with 14 calculations for p.

So overall we have 24 candidates to check, one of which is the unique solution. The brute force program above checks all 480 possibilities (although it does so a lot faster than going through the 24 candidates by hand).