**From New Scientist #1518, 24th July 1986** [link]

“My memory is poor, but accurate,” said Mooncalf. “I remember just enough of the characteristics of my safe combination to enable me to reconstruct the number when I forget it. It contains a pair of 1s separated by one digit, a pair of 2s separated by two digits, a pair of 3s separated by three digits and so on, there being twice as many digits in the number as the value of the highest digit. Yet I can’t even remember the highest pair of digits.”

“There must be many such numbers,” I opined, reaching for my notepad. “For example, 312132. That has two 1s separated by one digit, two 2s separated by two digits and two 3s separated by three digits.”

“Yes. But what makes my safe number unique is that it is the highest number that can be formed in this way. As an *aide-mémoire*, I have written part of it on a card. If anyone stumbles across it he is unlikely to tumble to its true significance. First I write the safe number backwards. Then, starting from the right I discard from this number, one by one, as many digits as I can, consistent with there occurring at least once in the number which remains each digit of the original number. This final number is my *aide-mémoire*.”

“You mean if it were 41312432 you would be left with 23421 on the card?”

“Exactly. But I have locked it away in the safe, and I want you to help me to deduce my combination so I can open the safe and retrieve it.”

Scratching my head, I got down to work. In no time at all I had deduced the number and had retrieved Mooncalf’s card.

What was the number inscribed on it?

[enigma369]

### Like this:

Like Loading...

This Python 3 program runs in 393ms.

Solution:The number on the card is 1317538642.The combination to the safe is 8642752468357131.

I know it doesn’t fit the puzzle as stated, but would it work with a 00 somewhere?

That’s a pair of zeros separated by no digits.

@Hugh: If we look for a sequence of

2n + 2digits (instead of2ndigits), then we can get:as the highest such number.

And the corresponding number on the card would be:

Thanks, Jim. I got a bit bogged down when I tried to write a program for that.

Did anyone find a way of testing and/or assembling the possible sequences of numbers without the benefit of a search with a program? I used a graphic approach but, inevitably, it was too time consuming as the number of digits increased.