A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
class Integer
def palindromic?
self.to_s == self.to_s.reverse
end
end
12321.palindromic?
true
result = []
(111..999).lazy.each do |x|
(111...999).lazy.each do |y|
temp = x * y
result << temp if temp.palindromic?
end
end
result.max
906609