Commits

Martin Klinke committed 337c9e7

simplified solution

  • Participants
  • Parent commits e8a6338

Comments (0)

Files changed (1)

src/com/mklinke/euler/Problem33.scala

 
   def main(args: Array[String]) {
 
-    val result = (1 to 99).map(num =>
-      num to 99 map (denom => new Rational(num, denom)) filter (rational => check(rational)))
-
-    val filtered = result.filter(_.length > 0)
-    val mapped = filtered.map(entry => entry.reduceLeft(_ * _))
-    val product = mapped.reduceLeft(_ * _).simplify
+    val product = (1 to 99).map(
+      num => num to 99 map (denom => new Rational(num, denom)) filter (rational => check(rational)))
+      .filter(_.length > 0)
+      .flatten
+      .reduceLeft(_ * _)
+      .simplify
 
     Console println product
   }