Skip to content

Instantly share code, notes, and snippets.

@jwhitehorn
Created October 14, 2014 02:04
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 jwhitehorn/f1a0d5e88a39bdd7454d to your computer and use it in GitHub Desktop.
Save jwhitehorn/f1a0d5e88a39bdd7454d to your computer and use it in GitHub Desktop.
Backronym Generator
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