Code Words by John Biesnecker

On the importance of knowing the standard library 20 Jan 2012


I spent a little times working through some 4clojure problems today. I'm getting better at them, but I was stuck on #77: Anagram Finder for way too damn long.

The solution I finally came up with was:

For those of you following at home, that's a total of four anonymous functions which take the list of words, turn it into a map with the sorted version of each word as a key and a hash set of matching words as the value, then it turns the whole thing into a hash set, then it filters out sets that have less than 2 elements, and then it turns the final return value into a hash set again.

Phew!

Here, however, is a good solution to the problem:

The difference (besides seemingly hundreds of characters) between the two? Inecas knew about the group-by function, and I didn't.

Sigh.

"Ah, but a man's reach should exceed his grasp, or what's a heaven for?"