Rewrote Norvig's Solution in Scala