Skip to content

Instantly share code, notes, and snippets.

@kyleplo
Created April 19, 2023 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyleplo/ff435c01178ec35572d9c393904ddefd to your computer and use it in GitHub Desktop.
Save kyleplo/ff435c01178ec35572d9c393904ddefd to your computer and use it in GitHub Desktop.
// 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