Skip to content

Instantly share code, notes, and snippets.

@evansneath
Created August 20, 2011 23:14

Revisions

  1. evansneath revised this gist Aug 20, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion palindromes.py
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ def palindromes(min, max):
    while a < max:
    while b < max:
    product = a * b
    # determine if the product is reverible
    # determine if the product is reversible
    if str(product)[::-1] == str(product):
    if product > highest:
    highest = product
  2. evansneath revised this gist Aug 20, 2011. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion palindromes.py
    Original file line number Diff line number Diff line change
    @@ -11,9 +11,11 @@ def palindromes(min, max):
    while a < max:
    while b < max:
    product = a * b
    if str(product)[::-1] == str(product): # if reversible...
    # determine if the product is reverible
    if str(product)[::-1] == str(product):
    if product > highest:
    highest = product
    b = b + 1
    a, b = a + 1, min

    return highest
  3. evansneath created this gist Aug 20, 2011.
    19 changes: 19 additions & 0 deletions palindromes.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    def palindromes(min, max):
    """Finds the largest palindrome of the product of two numbers between an desired range.
    Arguments:
    min: Minimum value limit.
    max: Maximum value limit.
    Returns:
    Largest palindrome of the product of two numbers between the established range.
    """
    a, b, product, highest = min, min, 0, 0
    while a < max:
    while b < max:
    product = a * b
    if str(product)[::-1] == str(product): # if reversible...
    if product > highest:
    highest = product
    b = b + 1
    a, b = a + 1, min
    return highest