init
This commit is contained in:
30
assign_colours.py
Normal file
30
assign_colours.py
Normal file
@ -0,0 +1,30 @@
|
||||
#!/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)
|
Reference in New Issue
Block a user