Skip to content

Instantly share code, notes, and snippets.

@cesarkawakami
Last active August 29, 2015 14:06
Show Gist options
  • Save cesarkawakami/ab4a60be64984d222107 to your computer and use it in GitHub Desktop.
Save cesarkawakami/ab4a60be64984d222107 to your computer and use it in GitHub Desktop.
import string
def product(*vectors):
if len(vectors) == 0:
yield ()
else:
for element in vectors[0]:
for tail in product(*vectors[1:]):
yield tuple(element) + tail
def generate_strings():
current_length = 0
while True:
current_length += 1
for element in product(*[string.ascii_lowercase] * current_length):
yield "".join(element)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment