SHARE
TWEET

permutations.py

Procy0n Jun 4th, 2011 314 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2. import itertools
  3.  
  4. # Argument 1: Maximum number of elements used
  5. maxlen = int(sys.argv[1])
  6.  
  7. # Argument 2: File containing the elements, one per line
  8. wordlist = open(sys.argv[2])
  9.  
  10.  
  11. words = [w.strip() for w in wordlist]
  12.  
  13. for i in range(1, maxlen + 1):
  14.     for l in itertools.permutations(words, i):
  15.         print "".join(l)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top