----- Python code description -----
Initial lists are integers with the desired group of digits sorted in decreasing order to avoid having to deal with leading zeros.
The program checks every 5 digit number which is divisible by 55,
The integer "i" is converted to integer "j" with the digits rearranged in decreasing order using string functions.
Then check to see if "j" is in one of the lists.
----- code -----
listNoWrap = [43210,54321,65432,76543,87654,98765]
listWrap = [98760,98710,98210,93210]
count = 0
for i in range(10010,100000,55):
s = str(i)
srt = sorted(list(s))
srt.reverse()
compress = ''
for a in srt:
compress = compress + a
j = int(compress)
if j not in (listNoWrap):
# if j not in (listWrap):
continue
print (i)
count += 1
print(count)
--- the 20 valid solutions (no wrapping around) and the 16 extra solutions if wrapping around allowed.
12430
13420
21340
24310
24365
26345
31240
34210
34265
36245
42130
43120
47685
48675
63745
64735
67485
68475
73645
74635
20 listNoWrap
12980
18920
21890
29810
67980
68970
76890
79860
81290
86790
89210
89760
92180
97680
98120
98670
16 listWrap
|
Posted by Larry
on 2021-02-27 17:01:19 |