Failed Scala entry to problem B in 2014 round 1C

Got out of memory issue on case #57 of the small problem. It would also
make sense to take modulo's on every multiplication to prevent
arithmetic overflow.

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Unknown Source)
at java.lang.AbstractStringBuilder.expandCapacity(Unknown Source)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(Unknown
Source)
at java.lang.AbstractStringBuilder.append(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at
scala.collection.mutable.StringBuilder.append(StringBuilder.scala:197)
at
ProblemBSolverApp$$anonfun$tryCombineStrings$1.apply(ProblemBSolverApp.scala:109)
at
ProblemBSolverApp$$anonfun$tryCombineStrings$1.apply(ProblemBSolverApp.scala:100)
at scala.collection.immutable.List.foreach(List.scala:318)
at ProblemBSolverApp$.tryCombineStrings(ProblemBSolverApp.scala:100)
at ProblemBSolverApp$.combineStrings(ProblemBSolverApp.scala:143)
at ProblemBSolverApp$.solve(ProblemBSolverApp.scala:161)
at
ProblemBSolverApp$$anonfun$solveAll$1$$anonfun$apply$mcV$sp$1.apply$mcVI$sp(ProblemBSolverApp.scala:193)
at scala.collection.immutable.Range.foreach$mVc$sp(Range.scala:141)
at
ProblemBSolverApp$$anonfun$solveAll$1.apply$mcV$sp(ProblemBSolverApp.scala:189)
at
ProblemBSolverApp$$anonfun$solveAll$1.apply(ProblemBSolverApp.scala:187)
at
ProblemBSolverApp$$anonfun$solveAll$1.apply(ProblemBSolverApp.scala:187)
at ProblemBSolverApp$.time(ProblemBSolverApp.scala:11)
at ProblemBSolverApp$.solveAll(ProblemBSolverApp.scala:187)
at ProblemBSolverApp$delayedInit$body.apply(ProblemBSolverApp.scala:215)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at
scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.collection.immutable.List.foreach(List.scala:318)
at
scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
at scala.App$class.main(App.scala:71)
at ProblemBSolverApp$.main(ProblemBSolverApp.scala:6)
at ProblemBSolverApp.main(ProblemBSolverApp.scala)
2014 round 1B: Scala solution to large problem B

A Scala solution that succeeds on the large problem set (taking 562
milliseconds to solve all the problems).

The C# solution took too long on the large problem set. I rewrote this
using a brand new algorithm. I used Scala to take advantage of pattern
matching.