**From New Scientist #2303, 11th August 2001** [link]

Matthew is practising his multiplication and addition. He had a board (as below) and nine cards labelled 1,2,3,…,8,9.

He shuffles the cards and deals them on to the board, one to each square. For each square, he multiplies the number on the board by the number on the card in that square. Finally he adds together the nine products he has obtained to give his final number.

When I watched Matthew play the game his final number was 545. When he had finished he then moved some of the cards. Each card he moved went one square horizontally or vertically, but not diagonally, to another square on the board. I can’t remember all the cards he moved, but I do know he moved the cards in the four corner squares. He then had a new layout with one card in each square and he repeated his multiply and add routine. When he told me his final number, I asked him how many factors it had. After a while he told me he had found 20 but had still not finished his search.

What was Matthew’s final number after he had moved the cards?

[enigma1147]

### Like this:

Like Loading...

*Related*

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.