Created
February 23, 2013 13:35
-
-
Save zerosum/5019765 to your computer and use it in GitHub Desktop.
Project Euler: Problem 38
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
| package euler.zerosum | |
| import euler.zerosum.Number._ | |
| object Euler0038 { | |
| private val nums = from(1).take(9999) | |
| private val digits = (1 to 9).toList | |
| private val nineDigitNums: Set[String] = digits.permutations.map(_.mkString).toSet | |
| def main(args: Array[String]) { | |
| println(nums | |
| .par | |
| .map(n => digits.scanLeft("")((a, b) => a + b * n).filter(nineDigitNums.contains(_)).headOption) | |
| .collect {case Some(x) => x} | |
| .max | |
| ) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment