title: Euler #4 in Python
body: <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.<br />
  Find the largest palindrome made from the product of two 3-digit numbers.</p>
  <p><a href="http://projecteuler.net/problem=4" rel="nofollow noreferrer">http://projecteuler.net/problem=4</a></p>
  </blockquote>
  <p>Below is my solution to this problem. It works, but I noticed another solution that used</p>
  <pre><code>if x*y &lt; max_seen: continue
  </code></pre>
  <p>like this:</p>
  <pre><code>def biggest():
      big_x, big_y, max_seen = 0, 0, 0
      for x in xrange(999,99,-1):
          for y in xrange(x, 99,-1): 
              if x*y &lt; max_seen: continue
              if is_palindrome(x*y):
                  big_x, big_y, max_seen = x,y, x*y
  </code></pre>
  <p>What I don't get is how that line works. The first time through <code>max_seen = 0</code> and the first <code>x*y</code> is <code>999*999</code> which is greater than 0. So that condition isn't met and the next line is run. Makes sense. Eventually, however, <code>max_seen</code> will be larger than <code>x*y</code> so why does it <code>continue</code> here?</p>
  <p>It seems this line isn't even needed because if the condition is or isn't met the program will continue anyway. I suspect I'm not understanding how <code>continue</code> works in Python.</p>
  <p>This is my approach:</p>
  <pre><code>def find_biggest():
      big_x, big_y, new_pal, max_seen = 0, 0, 0, 0
      for x in range(999, 100, -1):
          for y in range(x, 100, -1):
              if is_palindrome(x*y) == True:
                  new_pal = x*y
                  if new_pal &gt; max_seen:
                      big_x, big_y, max_seen = x, y, new_pal
  </code></pre>
  <p>From an efficiency standpoint the program should exit as soon as all new <code>x*y</code> are <code>&lt; max_seen</code>, but <code>999*100</code> is less than <code>998*900</code> (meaning it couldn't stop yet as it still needs to check <code>998*y</code>, <code>997*y</code>, etc.) so how would you code that?</p>