Snapshot permission updates.
This commit is contained in:
1 parent
414380740f
commit
d570b16b60
3 files changed
+43
-5
No files matched your search
@@ -61,10 +61,29 @@ class SimilaritySolver(object):
|
||||
for word in wordle_dictionary:
|
||||
scored_words[word] = self._score_word(position_matches, word_matches, word)
|
||||
|
||||
result = list(wordle_dictionary)
|
||||
result.sort(key=lambda word: scored_words[word], reverse=True)
|
||||
# Return as list of (word, score) sorted by high-score, word.
|
||||
result = sorted(scored_words.items(), key=lambda kv: kv[0])
|
||||
result = sorted(result, key=lambda kv: kv[1], reverse=True)
|
||||
return result
|
||||
|
||||
return [(word, scored_words[word]) for word in result]
|
||||
|
||||
class LimitsSolver(object):
|
||||
def scored_words(self, words=dictionary.words()):
|
||||
# word: score
|
||||
scored_words = dict()
|
||||
|
||||
for word in words:
|
||||
reduced = const.filter_words(words)
|
||||
|
||||
# Our score is how many words did we remove from consideration.
|
||||
score = len(words) - len(reduced)
|
||||
|
||||
scored_words[word] = score
|
||||
|
||||
# Return as list of (word, score) sorted by high-score, word.
|
||||
result = sorted(scored_words.items(), key=lambda kv: kv[0])
|
||||
result = sorted(result, key=lambda kv: kv[1], reverse=True)
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+20
-1
@@ -2,15 +2,18 @@
|
||||
|
||||
import unittest
|
||||
|
||||
import dictionary
|
||||
import solver
|
||||
|
||||
test_dictionary = dictionary.words()
|
||||
|
||||
|
||||
class TestSolver(unittest.TestCase):
|
||||
def test_SimilaritySolver(self):
|
||||
"""Minimal end to end test."""
|
||||
|
||||
solve = solver.SimilaritySolver()
|
||||
result = solve.scored_words()
|
||||
result = solve.scored_words(test_dictionary)
|
||||
|
||||
expected = [
|
||||
("cares", 139631),
|
||||
@@ -22,6 +25,22 @@ class TestSolver(unittest.TestCase):
|
||||
|
||||
self.assertListEqual(result[:5], expected)
|
||||
|
||||
def test_LimitsSolver(self):
|
||||
"""Minimal end to end test."""
|
||||
|
||||
solve = solver.LimitsSolver()
|
||||
result = solve.scored_words(test_dictionary)
|
||||
|
||||
expected = [
|
||||
("aahed", 5),
|
||||
("aalii", 5),
|
||||
("aargh", 5),
|
||||
("aaron", 5),
|
||||
("abaca", 5),
|
||||
]
|
||||
|
||||
self.assertListEqual(result[:5], expected)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -9,7 +9,7 @@
|
||||
"editor.defaultFormatter": "ms-python.black-formatter",
|
||||
"editor.formatOnSave": true,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.organizeImports": true
|
||||
"source.organizeImports": "explicit"
|
||||
},
|
||||
},
|
||||
"python.formatting.provider": "none",
|
||||
|
||||
Reference in new issue
Block a user