gotta switch computers

This commit is contained in:
2022-01-13 22:03:13 -05:00
parent ae669ff950
commit 5a29efd147

View File

@@ -1,6 +1,7 @@
#! /usr/bin/python #! /usr/bin/python3
import re import re
from string import ascii_lowercase
letterscore = { letterscore = {
"s": 26, "s": 26,
@@ -29,7 +30,6 @@ letterscore = {
"x": 3, "x": 3,
"j": 2, "j": 2,
"q": 1, "q": 1,
"\n": 0
} }
def trimWordList(toRemove, words): def trimWordList(toRemove, words):
@@ -40,12 +40,9 @@ def trimWordList(toRemove, words):
pass pass
def rankWord(word, words): def rankWord(word, words):
word=word.lower() score = sum(letterscore.get(letter, 0) for letter in word.lower())
score=0
for letter in word:
score=score+letterscore[letter]
multiplier=countDistinct(word) multiplier=len(set(word))
words[word] = score*multiplier words[word] = score*multiplier
return score*multiplier return score*multiplier
@@ -73,11 +70,9 @@ def rankLetters(words):
rank+=1 rank+=1
def matchKnown(mask, words): def matchKnown(mask, words):
toRemove = [] toRemove = [word for word in words if not re.search(mask, word)]
for word in words: (words.remove(word) for word in toRemove)
if not re.search(mask, word):
toRemove.append(word)
trimWordList(toRemove, words)
def removeExcluded(mask, words): def removeExcluded(mask, words):
toRemove = [] toRemove = []
@@ -164,5 +159,5 @@ if __name__ == "__main__":
for word in words: for word in words:
print str(words[word]) + " " + word print(str(words[word]) + " " + word)