Skip to content

Instantly share code, notes, and snippets.

@trevorblades
Created August 17, 2019 19:13
Show Gist options
  • Save trevorblades/add67b7858a460d0592c1b9bc8d7d78a to your computer and use it in GitHub Desktop.
Save trevorblades/add67b7858a460d0592c1b9bc8d7d78a to your computer and use it in GitHub Desktop.
function spellingBeeSolutions(wordList, puzzles) {
return puzzles.map(puzzle => {
const puzzleLetters = puzzle.split('');
return wordList.reduce((acc, word) => {
const letters = word.split('');
const match = letters.every(
letter => puzzleLetters.includes(letter)
);
return match ? acc + 1 : acc;
}, 0);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment