Skip to content

Instantly share code, notes, and snippets.

@mindjiver
Created April 25, 2011 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindjiver/941089 to your computer and use it in GitHub Desktop.
Save mindjiver/941089 to your computer and use it in GitHub Desktop.
Euler - Problem 24
#!/usr/bin/env python
# the number of permutations of a n length list is n!
from itertools import permutations, islice
# recipe from itertools library documentation.
def take(n, iterable):
"Return first n items of the iterable as a list"
return list(islice(iterable, n))
l = range(0, 10)
n = 1000000
print take(n, permutations(l))[-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment