2048 implementation in Scala