Ruby solution to Project Euler Problem #4: Largest palindrome product I've solved the Project Euler Problem #4, but I'd like some tips as to how to make this more efficient. I am a beginner to Ruby, so please be nice about the stupid stuffs (but still tell me about it).
Project Euler 4: Largest palindrome product

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.
1

class Euler4
  def isPalindrome(n)
    n == n.to_s.reverse.to_i
  end
end

  puts &quot;Setting Variables&quot;
  x = 999
  y = 999

  highest = 1

  found = false

  while (x &gt; 100 &amp;&amp; !found)
    y = 999
    while (y &gt; 100 &amp;&amp; !found)
      puts &quot;Working with&quot;
      puts x
      puts &quot; and &quot;
      puts y

      if Euler4.new.isPalindrome(x*y)
        puts &quot;Found Palindrome&quot;
        puts x
        puts y
        puts x*y
        if highest &lt; (x*y)
          highest = x * y
        end
      end
      y = y - 1
    end

    x = x - 1

  end

puts &quot;Highest Found&quot;
puts highest
Let's start with something small:

def isPalindrome(n)
  n == n.to_s.reverse.to_i
end


How do I know if a number is a palindrome?


Convert it to a string.
Produce the reverse of that string.
Convert the reversed string to a number.
Compare the numbers for equality.


As yourself: why did we need to do the last two steps?  We could have said:


Convert it to a string.
Produce the reverse of that string.
Compare the strings for equality.


and skipped the "convert to integer" step entirely.

Next small thing. I've removed every line of your program that does not use variable found:

found = false
while (x &gt; 100 &amp;&amp; !found)
  while (y &gt; 100 &amp;&amp; !found)


See any problems with that code? Because I don't see anywhere that it is set to true and therefore it will always be false. I'm not sure why a variable that is always false is of use to you.

Next thing: You check all pairs: (999, 999), (999, 998), ... (999, 101) and then start over again with (998, 999).  But you already checked (998, 999) when you checked (999, 998)! You don't need to start y at 999.  It suffices to start y at x.  Then you only check each pair once instead of checking the vast majority of them twice.

Next thing: If you find an (x, y) pair that is a palindrome, you don't need to check (x, y - 1); even if it is a palindrome, it will be smaller. Probably this is what you were trying to do with your "found" variable, but you never wrote the logic correctly.

Next thing: Remove all that print-debugging trace. If you need to debug your program, use a debugger.