-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstarters.py
executable file
·59 lines (38 loc) · 985 Bytes
/
starters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
"""
Generates starting words
"""
import random
import sys
with open("words.txt") as f:
all_words = [x.strip() for x in f]
with open("used.txt") as f:
used = [x.strip() for x in f]
words = set(all_words).difference(used)
def get_triple(starter):
starters = []
starters.append(starter)
for word in words:
if word == starter:
continue
if len(set(word)) != 5:
continue
is_valid = True
for w in starters:
if set(w).intersection(set(word)) != set(): # nothing in common
is_valid = False
if is_valid:
starters.append(word)
if len(starters) == 3:
break
for start in starters:
print(start)
def main():
if len(sys.argv) > 1:
given = sys.argv[1].strip()
else:
given = random.choice(list(words))
get_triple(given)
sys.exit(0)
if __name__ == "__main__":
main()