Initial commit
This commit is contained in:
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Auto detect text files and perform LF normalization
|
||||||
|
* text=auto
|
||||||
21952
cleaned_words.txt
Normal file
21952
cleaned_words.txt
Normal file
File diff suppressed because it is too large
Load Diff
20
data_cleaner.py
Normal file
20
data_cleaner.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
input_file_path = 'source_words.txt'
|
||||||
|
output_file_path = 'cleaned_words.txt'
|
||||||
|
|
||||||
|
input_file = open(input_file_path, 'r')
|
||||||
|
output_file = open(output_file_path, 'w')
|
||||||
|
|
||||||
|
def is_five_characters(word):
|
||||||
|
return len(word) == 5
|
||||||
|
|
||||||
|
def is_only_letters(word):
|
||||||
|
return word.isalpha()
|
||||||
|
|
||||||
|
|
||||||
|
for line in input_file:
|
||||||
|
word = line.strip()
|
||||||
|
if is_five_characters(word) and is_only_letters(word):
|
||||||
|
output_file.write(word.lower() + '\n')
|
||||||
|
|
||||||
|
input_file.close()
|
||||||
|
output_file.close()
|
||||||
466550
source_words.txt
Normal file
466550
source_words.txt
Normal file
File diff suppressed because it is too large
Load Diff
40
wordle_solver.py
Normal file
40
wordle_solver.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
input_file_path = 'cleaned_words.txt'
|
||||||
|
|
||||||
|
dictionary = open(input_file_path, 'r')
|
||||||
|
|
||||||
|
char_not_in_word = ''
|
||||||
|
char_in_word = ''
|
||||||
|
|
||||||
|
# go through the dictionary and find the words that have the given characters
|
||||||
|
def words_with_letters(letters, dictionary):
|
||||||
|
num_letters = len(letters)
|
||||||
|
valid_words = []
|
||||||
|
for word in dictionary:
|
||||||
|
word = word.strip()
|
||||||
|
match_amount = 0
|
||||||
|
for letter in letters:
|
||||||
|
if letter in word:
|
||||||
|
match_amount += 1
|
||||||
|
if match_amount == num_letters:
|
||||||
|
valid_words.append(word)
|
||||||
|
|
||||||
|
return valid_words
|
||||||
|
|
||||||
|
def words_without_letters(letters, dictionary):
|
||||||
|
valid_words = []
|
||||||
|
for word in dictionary:
|
||||||
|
word = word.strip()
|
||||||
|
is_valid = True
|
||||||
|
for letter in letters:
|
||||||
|
if letter in word:
|
||||||
|
is_valid = False
|
||||||
|
break
|
||||||
|
if is_valid:
|
||||||
|
valid_words.append(word)
|
||||||
|
|
||||||
|
return valid_words
|
||||||
|
|
||||||
|
def get_entropy(dict_size, valid_words)
|
||||||
|
|
||||||
|
valid_words = words_without_letters("ira", dictionary)
|
||||||
|
print(valid_words)
|
||||||
Reference in New Issue
Block a user