limit arguments to not support duplicate names

This commit is contained in:
2025-07-08 04:31:01 +01:00
parent 72cc87f5b6
commit fba074a5a4
7 changed files with 85 additions and 17 deletions

35
test.py Normal file
View File

@@ -0,0 +1,35 @@
import string
from itertools import product
import sys
def generate_names(max_width, skip_keywords=None):
if skip_keywords is None:
skip_keywords = {"if", "else", "while", "forever", "for", "break", "continue",
"return", "let", "import", "from", "do", "true", "false", "null",
"delete", "not", "try", "catch", "in"}
else:
skip_keywords = set(skip_keywords)
chars = string.ascii_lowercase
first = True
write = sys.stdout.write
for length in range(1, max_width + 1):
print(length, file=sys.stderr)
i = 0
for p in product(chars, repeat=length):
name = ''.join(p)
if name in skip_keywords:
continue
if not first:
write('\n')
write(name)
first = False
if i>10000000:
break
i+=1
# Example usage:
max_width = 15
# sys.stdout.write("let ")
generate_names(max_width)