Sunday Times Teaser 2984 – Shuffle the Cards
by Victor Bryant
Published December 1 2019 (link)
In the classroom I have a box containing ten cards each with a different digit on it. I asked a child to choose three cards and to pin them up to make a multiplication sum of a one-figure number times a two-figure number. Then I asked the class to do the calculation.
During the exercise the cards fell on the floor and a child pinned them up again, but in a different order. Luckily the new multiplication sum gave the same answer as the first and I was able to display the answer using three of the remaining cards from my box.
What was the displayed answer?
One Comment
Leave one →
-
Brian Gladman permalink123456789101112131415161718192021from itertools import permutations# choose three cards from the boxfor p in permutations(range(10), 3):a, b, c = p# ensure one and two digit numbersif a > 1 and b:# do the multiplicationmm = a * (10 * b + c)# ... whose three digits must remain in the boxdgts = set(int(x) for x in str(mm))if len(dgts) == 3 and dgts < set(range(10)).difference(p):# rearrange the three digitsfor q in permutations(p):# to give a different permutationif q != p and q[0] > 1 and q[1]:# for which the multiplication gives the same answerif q[0] * (10 * q[1] + q[2]) == mm and p < q:print(f"{mm} ({p[0]} x {p[1]}{p[2]}), cards = {p}, {q}")