Sunday Times Teaser 3337 – Hidden PINs
by Andrew Skidmore
Published Sunday September 06 2026
Richard has opened a bank account. The bank has issued him with a telephone PIN and a debit card PIN; both are four-figure numbers. The telephone PIN is a perfect square; its square root can be obtained from the card PIN if the first two digits are deleted from the card PIN. The card PIN is composed of four different digits in decreasing order; none of these digits occur in the telephone PIN.
If I told you whether the telephone PIN has a repeat digit you would be able to find both PINs.
What is the debit card PIN?
5 Comments
Leave one →
Borrowing heavily from Brian’s original code but not assuming repeat digits
Hi John,
Some interesting variations on how to do simple steps here. Your dictionary initialisation is certainly a simple way of setting up ia dictionary and avoiding a defaultdict import. My approach using get is OK on small dictionaries but can be very bad on large ones as it creates a new list on each list extension.
Another thing, one that Frits has to keep reminding me of, is the difference between set().intersection() and set().isdisjoint(). It has the same issue for large sets since intersection() creates a new set whereas isdisjoint() does not and will be much faster on large sets when you don’t need the resulting set. Of course it doesn’t matter here but it is a useful detail to remember (at least if your memory is better than mine!).
Hi Brian,
It would have been simpler if I had used a list (or tuple) rather than a dictionary as we know the indices ahead of time and they start with 0 and of course end with 1.
I will try to remember the disjoint method