Created
November 21, 2012 16:21
-
-
Save daiksy/4125799 to your computer and use it in GitHub Desktop.
Project Euler Problem 8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * http://projecteuler.net/problem=8 | |
| * http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%208 | |
| */ | |
| val s = "7316717 ... 63450" // 途中省略してます. | |
| val xs = s.toList.map(_.toString.toInt) | |
| def product(xs: List[Int], ys: List[Int]): List[Int] = { | |
| xs match { | |
| case a :: b :: c :: d :: e :: tail => product(xs.tail, a * b * c * d * e :: ys) | |
| case _ => ys | |
| } | |
| } | |
| val ret = product(xs, Nil) max | |
| println(ret) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment