Created
January 15, 2013 11:36
-
-
Save kazua/4538016 to your computer and use it in GitHub Desktop.
Project Euler Problem 32
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://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2032 | |
| //K.A | |
| object problem32 { | |
| def problem32 = (1 to 99).map(i => if (i < 10) (1000 to 9999).map(j => List(i, j, (i * j))) | |
| else (100 to 999).map(j => List(i, j, (i * j))) | |
| ).flatten.filter(_.mkString.length == 9) | |
| .filter(k => (1 to 9).map(m => k.mkString.indexOf(m.toString)).forall(n => n >= 0)) | |
| .map(_.last).distinct.sum | |
| def main(args : Array[String]) { | |
| println(problem32) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment