Skip to content

Instantly share code, notes, and snippets.

@jee1mr
Created March 16, 2020 06:11
Show Gist options
  • Save jee1mr/4780223cf01fb6d044391291c23a7b77 to your computer and use it in GitHub Desktop.
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
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