Project Euler 24 Lexicographic Permutations in Python

Publicado el: 03 febrero 2018
en el canal de: Jeffrey James
1,996
10

https://projecteuler.net/problem=24

Python allows for a remarkably compact solution to this one. First call permutations on a string of the 0-9 digits. Then join them all to a string, which we ultimately map the int function onto. Then we return the millionth element of the sorted list.

from itertools import permutations

def problem24():
vals = list(permutations('0123456789'))
vals = ["".join(x) for x in vals]
vals = list(map(int, vals))
final = sorted(vals)
return final[1000000]

2783915604


En esta página del sitio puede ver el video en línea Project Euler 24 Lexicographic Permutations in Python de Duración hora minuto segunda en buena calidad , que subió el usuario Jeffrey James 03 febrero 2018, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 1,996 veces y le gustó 10 a los espectadores. Disfruta viendo!