Skip to content

Instantly share code, notes, and snippets.

@daiksy
Created November 14, 2012 15:42
Show Gist options
  • Save daiksy/4072852 to your computer and use it in GitHub Desktop.
Save daiksy/4072852 to your computer and use it in GitHub Desktop.
Project Euler Problem 4
/**
* http://projecteuler.net/problem=4
* http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%204
*/
val xs = List.range(999, 99, - 1)
val ys = List.range(999, 99, - 1)
val isPalindromicNumber = (n: Int) => {
n.toString == n.toString.reverse
}
val ret = xs.map{ x =>
ys.map(y => if (isPalindromicNumber(x * y)) x * y else 0).max
}.max
println(ret)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment