### Random Post

### Recent Posts

- Tantalizer 450: Marriage problems
- Enigma 1057: Recycled change
- Enigma 452: Figure out these letters
- Puzzle 46: I lose my specs
- Enigma 1058: A row of colours
- Enigma 451: Double halved
- Tantalizer 451: Death rates
- Enigma 1059: Century break
- Enigma 450: A pentagonal problem
- Puzzle 48: Verse on the island

### Recent Comments

Jim Randell on Tantalizer 450: Marriage … | |

Brian Gladman on Enigma 1057: Recycled cha… | |

Jim Randell on Enigma 1057: Recycled cha… | |

geoffrounce on Enigma 452: Figure out these… | |

Jim Randell on Enigma 452: Figure out these… |

### Archives

### Categories

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

### Site Stats

- 184,975 hits

Advertisements

The first program I wrote looked at all possible arrangements of the cards, and picked out those with a value of 545, and those with a value with more than 20 divisors, and then tried to match the two so the second was an appropriate rearrangement of the first. This does produce the solution to the puzzle, but not particularly quickly (it runs in just under 1 second (999ms to be exact)).

My second approach was to use a bit of analysis to find out the possible rearrangements. It turns out there are only four allowable rearrangements. It also turns out there are only three arrangements of cards that give a total sum of 545. So we can apply each of the four rearrangements to these three initial arrangements of cards to give 12 candidate final arrangements. Only one of them has a total sum with more than 20 divisors.

This Python 3 program uses a recursive routine to find the possible arrangement of cards that give a sum of 545, and then applies the 4 rearrangements to each arrangement it finds, and works out the final sum. It runs in 82ms (and the code is slightly shorter than my original program too).

Solution:Matthew’s final number is 630.Here are the initial and final arrangements:

The positions of the coloured pairs are swapped between the initial and final arrangements.