Created
July 8, 2022 14:32
-
-
Save akipham15/4bfd0ca706b0c888059741c16d80f9ad to your computer and use it in GitHub Desktop.
generate-permutations-with-repetitions
This file contains hidden or 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 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