Created
August 22, 2012 05:51
-
-
Save stingh711/3422677 to your computer and use it in GitHub Desktop.
Project euler problem 4 solution
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
| object Issue4 { | |
| val MIN = 100 | |
| val MAX = 999 | |
| def isPalindromic(n: Int) = { | |
| val s = n.toString | |
| s == s.reverse | |
| } | |
| def maxPalindromic() = { | |
| val palindromics = for (i:Int <- MAX.to(MIN, -1); j:Int <- MAX.to(MIN, -1); n = i * j; if (isPalindromic(n))) | |
| yield n | |
| palindromics.max | |
| } | |
| def main(args: Array[String]) { | |
| assert(906609 == maxPalindromic()) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment