Teaser 3085: Lucky progression
From The Sunday Times, 7th November 2021 [link] [link]
I wrote down a number which happened to be a multiple of my lucky number. Then I multiplied the written number by my lucky number to give a second number, which I also wrote down. Then I multiplied the second number by my lucky number again to give a third, which I also wrote down. Overall, the three numbers written down used each of the digits 0 to 9 exactly once.
What were the three numbers?
[teaser3085]
Jim Randell 4:44 pm on 5 November 2021 Permalink |
The following Python program runs in 51ms.
Run: [ @replit ]
from enigma import irange, inf, nsplit, flatten, printf # consider lucky numbers, n for n in irange(2, inf): # and the initial multiple for k in irange(2, inf): # the three numbers ns = list(k * n ** x for x in (1, 2, 3)) # collect the digits in the numbers ds = flatten(nsplit(n) for n in ns) if len(ds) > 10: break if len(ds) == 10 and len(set(ds)) == 10: printf("ns = {ns} [n = {n}; k = {k}]") if k == 2: breakSolution: The three numbers are: 306, 918, 2754.
The lucky number is 3.
So we have:
LikeLike
GeoffR 5:34 pm on 5 November 2021 Permalink |
LikeLike
NigelR 5:51 pm on 5 November 2021 Permalink |
First number must be less than 1000 or the three numbers would have more than 10 digits between them. Code below runs in 39ms:
for lucky in range(1,100): for first in range(1,1000): if first%lucky!=0: continue second = first*lucky third = second*lucky res=str(first)+str(second)+str(third) if len(set(res)) == 10 and len(res) == 10: print (‘first: ‘, first,’ second: ‘, second,’ third:’, third,’ lucky:’, lucky) exit()LikeLike
GeoffR 8:52 am on 6 November 2021 Permalink |
# Assume a digit split of 3:3:4 for 10 digits for three numbers. # The multiplier is less than 10 between two increasing 3-digit numbers # The three numbers are ABC, DEF and GHIJ and the lucky number is LN from enigma import nsplit, all_different from enigma import Timer timer = Timer('ST3085') timer.start() for LN in range(2, 10): for ABC in range(102, 987): if ABC % LN != 0: continue A, B, C = nsplit(ABC) if not all_different(A, B, C): continue DEF = ABC * LN if DEF < 100 or DEF > 999: continue D, E, F = nsplit(DEF) if not all_different(A, B, C, D, E, F): continue GHIJ = DEF * LN if GHIJ < 1000 or GHIJ > 9999: continue G, H, I, J = nsplit(GHIJ) if not all_different(A, B, C, D, E, F, G, H, I, J): continue print(f"My three numbers are {ABC}, {DEF} and {GHIJ}") timer.stop() timer.report() # 4.98ms (I9 processor)LikeLike
Frits 10:33 am on 9 November 2021 Permalink |
@GeoffR, a digit split of 2:3:5 is also possible.
LikeLike
GeoffR 11:09 am on 9 November 2021 Permalink |
@Frits:
I decided to try a 3:3:4 digit split first as this seemed a more likely candidate for a solution. As this digit split gave a single answer, I did not try a 2:3:5 digit split.
LikeLike