This commit is contained in:
Ben Harris committed 2018-10-09 02:50:10 -04:00
1 parent a8a5de36f2
commit 58753c7234
38 files changed
+4549 -2523

No files matched your search

+16 -5
View File
@@ -6,6 +6,7 @@ p = inflect.engine()
dictionary = "/usr/share/dict/american-english-small"
BAD_WORDS_FILE = "badwords.txt"
def get_wordlist():
# I feel weird calling this "get_wordlist" when it's a generator without calling out that I do in fact realise it's weird - ~deltawitch
with open(BAD_WORDS_FILE, "r") as fp:
@@ -15,20 +16,29 @@ def get_wordlist():
if "'" not in word and word not in bad_words:
yield word.rstrip()
def get_puzzle():
dict_words = list(get_wordlist())
words = random.sample(dict_words, 3)
key = random.randrange(0,3) #get values 1-3
puzzle = "When alphebetized, what is the " + p.ordinal(p.number_to_words(key+1)) + " in " + ", ".join(words)
key = random.randrange(0, 3) # get values 1-3
puzzle = (
"When alphebetized, what is the "
+ p.ordinal(p.number_to_words(key + 1))
+ " in "
+ ", ".join(words)
)
words.sort()
answer = words[key]
return [answer, puzzle]
def get_anagram(maxlen = 6):
dict_words = [word for word in get_wordlist() if len(word) > 2 and len(word) <= maxlen+1]
def get_anagram(maxlen=6):
dict_words = [
word for word in get_wordlist() if len(word) > 2 and len(word) <= maxlen + 1
]
word = random.choice(dict_words)
while True:
anagram = ''.join(random.sample(word, len(word)))
anagram = "".join(random.sample(word, len(word)))
if anagram != word:
break
puzzle = "Unscramble the following word: '" + anagram + "'"
@@ -43,4 +53,5 @@ def get_anagram(maxlen = 6):
return False
# Ok, gotta actually check if it's a word now
return any(guess == item for item in get_wordlist())
return [answer_checker, puzzle]