Skip to content

Instantly share code, notes, and snippets.

@franga2000
Created October 21, 2017 21:10
Show Gist options
  • Save franga2000/0885de28a1392d72f51eff35d5a9520d to your computer and use it in GitHub Desktop.
Save franga2000/0885de28a1392d72f51eff35d5a9520d to your computer and use it in GitHub Desktop.
"""
Generates iterations of string from lines in a file
Usage: permutations.py <filename:str> <number:int>
Example: permutations.py wordlist.txt 2
"""
import sys
from itertools import permutations
f = sys.argv[1]
n = int(sys.argv[2])
l = [s.strip() for s in open(f).readlines()]
for p in permutations(l, n):
print("".join(p))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment