Last active
August 16, 2019 21:59
-
-
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
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
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