Skip to content

Instantly share code, notes, and snippets.

@capndesign
Last active November 2, 2023 05:16
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 capndesign/72d3359c5661a88b9c1bf682cc7c3d46 to your computer and use it in GitHub Desktop.
Save capndesign/72d3359c5661a88b9c1bf682cc7c3d46 to your computer and use it in GitHub Desktop.
Spelling Bee Help
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`))
@capndesign
Copy link
Author

And then I ran node spelling-bee.js | pbcopy and pasted it into a spreadsheet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment