Created
April 19, 2023 18:44
-
-
Save kyleplo/ff435c01178ec35572d9c393904ddefd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// assumes that wordList is a string containing the latest Wordle word list, which can be found at https://gist.githubusercontent.com/dracos/dd0668f281e685bad51479e5acaadb93/raw/valid-wordle-words.txt | |
// if running in the console of that page, uncomment the following line | |
// const wordList = document.body.textContent; | |
const words = wordList.split("\n"); | |
const scores = {}; | |
words.forEach(word => { | |
if(word.length !== 5){ | |
return;// sanity check | |
} | |
for(var i = 0;i < 5;i++){ | |
const masked = word.split(""); | |
masked[i] = "#"; | |
const joined = masked.join(""); | |
if(scores[joined]){ | |
scores[joined]++; | |
}else{ | |
scores[joined] = 1; | |
} | |
} | |
}); | |
const scoreList = []; | |
Object.keys(scores).forEach(mask => { | |
scoreList.push({ | |
mask: mask, | |
score: scores[mask] | |
}); | |
}); | |
const sorted = scoreList.sort((a, b) => b.score - a.score); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment