Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save akipham15/4bfd0ca706b0c888059741c16d80f9ad to your computer and use it in GitHub Desktop.
Save akipham15/4bfd0ca706b0c888059741c16d80f9ad to your computer and use it in GitHub Desktop.
generate-permutations-with-repetitions
import itertools
import time
CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def generate_char(char_length: int):
for payload in itertools.product(CHARACTERS, repeat=char_length):
yield ''.join(payload)
def main():
char_length = 6
get_payload = generate_char(char_length)
while True:
try:
# get next value
payload = get_payload.__next__()
# sleep
time.sleep(0.05)
print(payload)
except StopIteration:
print('Done!')
# stop when done
break
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment