Last active
November 2, 2023 05:16
-
-
Save capndesign/72d3359c5661a88b9c1bf682cc7c3d46 to your computer and use it in GitHub Desktop.
Spelling Bee Help
This file contains hidden or 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
const letters = ["P", "H", "A", "D", "L", "E", "N"] | |
const middleLetter = "H" | |
const wordStart = "PE"; | |
let possibleWords = []; | |
const updateWordList = (words, maxLength) => { | |
if (!words[0] || words[0].length < maxLength) { | |
const newWords = words.map(word => { | |
return letters.map((letter) => { | |
return word.concat(letter); | |
}) | |
}) | |
const unique = Array.from(new Set(newWords.flat())) | |
updateWordList(unique, maxLength) | |
} else { | |
possibleWords = words.filter(fragment => | |
fragment.includes(middleLetter) | |
).sort() | |
} | |
} | |
updateWordList(Array(6).fill(wordStart), 6) | |
console.log(possibleWords.join(`\n`)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And then I ran
node spelling-bee.js | pbcopy
and pasted it into a spreadsheet.