Skip to content

Commit

Permalink
Massive speed up on e004.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimweirich committed Sep 9, 2009
1 parent e3a4170 commit 71ceb57
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion e004.rb
Expand Up @@ -6,4 +6,11 @@ def palindrome?
end
end

p (100..999).map { |i| (i..999).map { |j| i*j } }.flatten.select { |n| n.palindrome? }.max
answer = 0
(100..999).each do |i|
(i..999).each do |j|
n = i*j
answer = n if n > answer && n.palindrome?
end
end
p answer

0 comments on commit 71ceb57

Please sign in to comment.