Initial commit.
This commit is contained in:
commit
85d28346bb
5 changed files with 370161 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
**/*.pyc
|
||||||
|
**/__pycache__/**
|
43
find_words.py
Normal file
43
find_words.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
# Find words based on letters given
|
||||||
|
|
||||||
|
from read_english_dictionary import load_words
|
||||||
|
from sys import argv
|
||||||
|
|
||||||
|
def create_bank(letters):
|
||||||
|
lb = {}
|
||||||
|
for l in letters:
|
||||||
|
if(l in lb):
|
||||||
|
lb[l] += 1
|
||||||
|
else:
|
||||||
|
lb[l] = 1
|
||||||
|
|
||||||
|
return lb
|
||||||
|
|
||||||
|
def main(letters):
|
||||||
|
wdb = load_words()
|
||||||
|
|
||||||
|
for w in wdb:
|
||||||
|
if(len(letters) >= len(w) and len(w) >= 3):
|
||||||
|
lb = create_bank(letters)
|
||||||
|
contains_letters = True
|
||||||
|
for l in w:
|
||||||
|
not_in = 0
|
||||||
|
for t in lb.keys():
|
||||||
|
if(l == t):
|
||||||
|
if(lb[l] > 0):
|
||||||
|
lb[l] -= 1
|
||||||
|
#print(lb)
|
||||||
|
else:
|
||||||
|
#lb = lb
|
||||||
|
contains_letters = False
|
||||||
|
else:
|
||||||
|
not_in += 1
|
||||||
|
|
||||||
|
if(not_in == len(lb.keys())):
|
||||||
|
contains_letters = False
|
||||||
|
|
||||||
|
if(contains_letters):
|
||||||
|
print(w)
|
||||||
|
|
||||||
|
if(__name__ == '__main__'):
|
||||||
|
main('catlle')
|
11
read_english_dictionary.py
Normal file
11
read_english_dictionary.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
def load_words():
|
||||||
|
with open('words_alpha.txt') as word_file:
|
||||||
|
valid_words = set(word_file.read().split())
|
||||||
|
|
||||||
|
return valid_words
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
english_words = load_words()
|
||||||
|
# demo print
|
||||||
|
print('fate' in english_words)
|
2
readme.md
Normal file
2
readme.md
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
### I forgot how to do headings in markdown and I'm too lazy to look it up
|
||||||
|
Word database and python script from: https://github.com/dwyl/english-words
|
370103
words_alpha.txt
Normal file
370103
words_alpha.txt
Normal file
File diff suppressed because it is too large
Load diff
Reference in a new issue