title: Finding palindromic numbers in Ruby
body: <p>So, I'm doing Project Euler to solidify my Ruby skills. I'm on problem #4, which reads:</p>
  
  <blockquote>
    <p>A palindromic number reads the same
    both ways. The largest palindrome made
    from the product of two 2-digit
    numbers is 9009 = 91 * 99.</p>
    
    <p>Find the largest palindrome made from
    the product of two 3-digit numbers.</p>
  </blockquote>
  
  <p>First, I'm trying to verify my code using the information from the first paragraph. I've defined a palindrome function as so:</p>
  
  <pre><code>def palindrome?(blah)
    string = blah.to_s
    string.reverse == string
  end
  </code></pre>
  
  <p>My code looks like:</p>
  
  <pre><code>array = (90..99).to_a
  array = array.map{|u| array.map{|y| u*y}}
  array = array.sort
  array = array.select{|u| palindrome?(u)}
  puts array
  </code></pre>
  
  <p>The program doesn't output anything. If I do the following:</p>
  
  <pre><code>array = (90..99).to_a
  array = array.map{|u| array.map{|y| u*y}}
  array = array.sort
  #array = array.select{|u| palindrome?(u)}
  puts array
  </code></pre>
  
  <p>I get a long series of unsorted four-digit numbers, so I guess it's ignoring the sort. Finally, if I simply do:</p>
  
  <pre><code>#array = (90..99).to_a
  #array = array.map{|u| array.map{|y| u*y}}
  #array = array.sort
  
  array = [7447, 9009, 3551, 2419]
  array = array.select{|u| palindrome?(u)}
  puts array
  </code></pre>
  
  <p>I get 7447 and 9009, like I should. Why is this happening?</p>
  
  <p>I'm using 1.8.6, because that's the only version available on this Windows machine.</p>