solution P28 (http://aperiodic.net/phil/scala/s-99/), it is a start