Sunday Times Teaser 2565 – Red and Black
Published: 20 November 2011 (link)
I have taken 10 cards and written a different digit on each one. Some of the cards are red and the rest are black. I have placed some of the red cards in a row to form a long number. Then I have moved the last card to the front to give me a larger number. In fact this larger number divided by the original one equals a digit on one of the black cards.
What was the original number?
One Comment
Leave one →
-
Brian Gladman permalink123456789101112131415161718192021222324252627282930313233# Let the number be 10.N + D where N has n digits and M be# the multiple involved. We then have:## 10^n.D + N = M.(10.N + D)## which gives:## N = (10^n - M).D / (10.M - 1)allow_leading_zeros = False# the number of digits in the N valuefor n in range(1, 10):# the last digit of the original numberfor D in range(1, 10):# the multiplefor M in range(2, 10):# look for values that result in an integer N valueN, r = divmod((10 ** n - M) * D, 10 * M - 1)if not r and (allow_leading_zeros or N >= 10 ** (n - 1)):# the original number and its digitsnbr = 10 * N + Ddigits = [int(x) for x in str(nbr)]# the multiple M is on a black card, i.e. not in the number# and all the red cards have different numbersif M not in digits and len(digits) == len(set(digits)):# the second number is the larger of the twoif nbr < 10 ** n * D + N:print(f'{nbr:0{n + 1}} ({M * nbr} = {M} x {nbr:0{n + 1}})')