Created
March 16, 2020 06:11
-
-
Save jee1mr/4780223cf01fb6d044391291c23a7b77 to your computer and use it in GitHub Desktop.
Python program for generating all possible combinations of small/upper case letters of a word
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 | |
word = sys.argv[1] | |
n = len(word) | |
num_of_combs = 2**n | |
for i in range(num_of_combs): | |
num = bin(i)[2:].zfill(n) # if cat 000, 001, 010.. if jack 0000, 0001, 0010... | |
print(''.join([ word[index].upper() if value == '1' else word[index].lower() for index, value in enumerate(num)])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment