Last active
August 29, 2015 13:57
-
-
Save strawberryjello/9527072 to your computer and use it in GitHub Desktop.
Sample usage of Python's itertools.permutations()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
"""Permutation generator | |
Just a sample usage of itertools.permutations() (Python 2.6 and later) | |
""" | |
import itertools | |
wordlist = list(itertools.permutations("estuyz")) | |
with open("permutations.txt", "wb") as f: | |
for word in wordlist: | |
for letter in word: | |
f.write(letter) | |
f.write("\n") | |
print "wrote", len(wordlist), "words" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment