Created
November 30, 2012 21:07
-
-
Save benbuckman/4178619 to your computer and use it in GitHub Desktop.
Revisions
-
Ben Buckman created this gist
Nov 30, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ dict = ['hello', 'kitty', 'farm'] isWordInDict = (word)-> (dict.indexOf(word) > -1) findAllWords = (str)-> words = [] for startInd in [0..(str.length - 1)] for endInd in [(startInd + 1)..str.length] word = str.substr startInd, endInd - startInd if isWordInDict word then words.push word words console.log findAllWords 'okhellokittynofarm'