Skip to content

Instantly share code, notes, and snippets.

@bchauSW
Last active August 16, 2019 21:59
Show Gist options
  • Save bchauSW/10e8f5c02ba15f26a1e63c3bb4171767 to your computer and use it in GitHub Desktop.
Save bchauSW/10e8f5c02ba15f26a1e63c3bb4171767 to your computer and use it in GitHub Desktop.
This script produces every possible pairing of letters from two words -- a letter from arg1 and a letter from arg2. Usage: python pairLettersInWords.py abcde fghij 12345
import sys
import itertools
if len(sys.argv) < 3:
print("Too few arguments -- at least 2 args are needed.")
exit(0)
print(len(sys.argv))
words = list(map(list, sys.argv[1:]))
result = [''.join(grouping) for grouping in list(itertools.product(*words))]
for grouping in result:
print(grouping)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment