Skip to content

Instantly share code, notes, and snippets.

@Riduidel
Created December 24, 2009 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Riduidel/263142 to your computer and use it in GitHub Desktop.
Save Riduidel/263142 to your computer and use it in GitHub Desktop.
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