Balda game solver in Scala