This is an implementation of http://asherv.com/threes/ in Scala