# Sunday Times Teaser 2781 – Five-Card Trick

*by Stephen Hogg*

#### Published October 1 2017 (link)

I have five cards with a different digit from 1 to 5 on each. I shuffled them and placed them face-down in a row to form a concealed five-figure number. Then I invited each of my six nephews to choose a number less than fifty and they happened to choose six consecutive numbers. Then I explained that there would be a prize for anyone whose number was a factor of the concealed number. No-one was certain to win but they were all in with a chance until I revealed the final digit of the number, which ruled out two of them from winning. Then I revealed the first digit and that ruled two more out. Then I revealed the whole number and just one nephew won a prize.

What was the concealed number?

Here’s my program. I collect the numbers that can be formed by the cards into a structure that can be indexed by

divisor,final digit,first digit, to make subsequent selections easier.This program requires the latest version of the

enigma.pylibrary [ http://www.magwag.plus.com/jim/enigma.html ] which includes the appropriateflattened()routine.