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.


In [4]:
class Integer
  def palindromic?
    self.to_s == self.to_s.reverse
  end
end

12321.palindromic?


Out[4]:
true

In [8]:
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


Out[8]:
906609