Created
October 14, 2014 02:04
-
-
Save jwhitehorn/f1a0d5e88a39bdd7454d to your computer and use it in GitHub Desktop.
Backronym Generator
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
lineReader = require 'line-reader' | |
words = {} | |
abbreviation = ['a', 'b', 'c'] | |
wordsForLetter = (thusFar, index) -> | |
letter = abbreviation[index] | |
for word in words[letter] | |
thusFar[index] = word | |
if index == abbreviation.length-1 | |
console.log thusFar.join ' ' | |
else | |
wordsForLetter thusFar, index+1 | |
lineReader.eachLine '/usr/share/dict/words', (line, last) -> | |
letter = line[0].toLowerCase() | |
if letter in abbreviation and line.length > 2 | |
words[letter] = [] unless words[letter]? | |
words[letter].push line | |
wordsForLetter [], 0 if last |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment