This paste expires on 2023-08-14 10:58:05.352572. Repaste, or download this paste. . Pasted through web.

# create score per word dict
scored_words = {word: self.score_word(word) for word in wordlist}
# # transpose to words per score dict
# words_per_score: Dict[int, [str]] = {}
# for word in wordlist:
#     word_score = scored_words[word]
#     if word_score in words_per_score:
#         words_per_score[word_score] += [word]
#     else:
#         words_per_score[word_score] = [word]
#
# # we want the highest scoring words first
# words_sorted_by_score = dict(sorted(words_per_score.items(), reverse=True))
#
# top_words: List[str] = []
# # we go through the highest scoring words first
# for _, words in words_sorted_by_score.items():
#     # then per score through the alphabetically sorted list of words with this score
#     for word in sorted(words):
#         # as long as we don’t have enough words we keep appending a word to the result
#         if len(top_words) < self.MAX_LEADERBOARD_LENGTH:
#             top_words.append(word)
#         else:
#             break
top_words_with_score = sorted([(-score, word) for word, score in scored_words.items()], reverse=False)
top_words = [word for score, word in top_words_with_score][:self.MAX_LEADERBOARD_LENGTH]
return top_words
Filename: None. Size: 1kb. View raw, , hex, or download this file.