Sunday Times Teaser 2950 – Ten Digits
by Andrew Skidmore
Published April 7 2019 (link)
Without repeating a digit I have written down three numbers, all greater than one.
Each number contains a different number of digits.
If I also write down the product of all three numbers, then the total number of digits I have used is ten.
The product contains only two different digits, each twice, neither of which appear in the three original numbers.
What is the product?
2 Comments
Leave one →

GeoffR permalink1234567891011121314151617181920212223242526272829303132from itertools import permutationsdig_set = set(range(10))# The three numbers are A, BC and DEFfor p in permutations(range(10), 6):A, B, C, D, E, F = p# ensure that A > 1 and no leading zerosif A == 1 or 0 in {A, B, D}:continue# form the numbers and their productBC, DEF = 10 * B + C, 100 * D + 10 * E + Fans = A * BC * DEF# check that the answer has four digitsif 1000 <= ans < 10000:# extract the digits of the answerW, X, Y, Z = t = [int(c) for c in str(ans)]# check there are only two different digits and that# they are different from those in A, BC, and DEFans_set = set(t)if len(ans_set) == 2 and not ans_set.intersection(p):# check that each digit occurs twice in the answerif all(t.count(x) == 2 for x in ans_set):print(f"Answer: {ans} ({A} x {B}{C} x {D}{E}{F})")