Files
common-words/assign_colours.py
Grail Finder 91f0e93961 init
2025-05-01 14:12:35 +03:00

31 lines
568 B
Python

#!/usr/env/bin python
from random import choice
FNAME = "nouns.txt"
# 9 for blue
# 8 for red
# 1 for black
# 7 for white
BLUENUM = 9
REDNUM = 8
BLACKNUM = 1
WHITENUM = 7
ALLNUMS = {"blue": BLUENUM, "red": REDNUM, "black": BLACKNUM, "white": WHITENUM}
di = {}
def assign_words(words, num):
resp = set()
while len(resp) < num:
resp.add(choice(words).strip())
return resp
if __name__ == "__main__":
with open(FNAME) as lf:
data = lf.readlines()
for k,num in ALLNUMS.items():
di[k] = assign_words(data, num)
print(di)