Skip to content

Instantly share code, notes, and snippets.

@zerosum
Created February 23, 2013 13:35
Show Gist options
  • Select an option

  • Save zerosum/5019765 to your computer and use it in GitHub Desktop.

Select an option

Save zerosum/5019765 to your computer and use it in GitHub Desktop.
Project Euler: Problem 38
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