Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
Add Comment
Please, Sign In to add comment