Consider all the (non leading zero) positive ten-digit pandigitals arranged in descending order..
Determine the millionth number on the list.
*** Computer program/spreadsheet assisted methodologies are welcome, but extra credit will be given for an analytical solution.
Of the 3265920 ten-digit pandigitals that do not start with zero and are in descending order, the millionth number on the list is 7216084539
-------------
from itertools import permutations
ds = '0123456789'
pans = []
for perm in permutations(ds):
if perm[0] == '0':
continue
pans.append(int(''.join(perm)))
panlist = sorted(pans)[::-1] # in order, then reverse the order
print( panlist[999999] ) # the list is zero based
|
Posted by Larry
on 2023-05-29 08:58:07 |