Created
December 24, 2009 10:47
-
-
Save Riduidel/263142 to your computer and use it in GitHub Desktop.
This file contains 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
start = System.currentTimeMillis(); | |
numbers = 100..999; | |
products=[]; | |
// Create all products | |
for(i in numbers) { | |
for(j in 100..i) { | |
products<<i*j; | |
} | |
} | |
println "finished computing products"; | |
// Now extract palindroms | |
palindroms = products.findAll { n -> | |
s = n.toString(); | |
s.equals(s.reverse()); | |
} | |
end = System.currentTimeMillis(); | |
println "duration : "+(end-start)/1000.0+" s."; | |
println palindroms.max(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment