Automatic commit performed through alias...
This commit is contained in:
@@ -13,10 +13,6 @@
|
|||||||
import decorators
|
import decorators
|
||||||
import time
|
import time
|
||||||
|
|
||||||
# Create function that finds the next
|
|
||||||
# prime number when supplied with an
|
|
||||||
# intitial integer.
|
|
||||||
|
|
||||||
def is_palindrome(candidate):
|
def is_palindrome(candidate):
|
||||||
"""
|
"""
|
||||||
Returns a boolean to confirm if the passed
|
Returns a boolean to confirm if the passed
|
||||||
@@ -31,20 +27,18 @@ def is_palindrome(candidate):
|
|||||||
# Convert maximum candidate to a list ...
|
# Convert maximum candidate to a list ...
|
||||||
listed_candidate = [int(i) for i in str(candidate)]
|
listed_candidate = [int(i) for i in str(candidate)]
|
||||||
flipped_candidate = [int(i) for i in str(candidate)]
|
flipped_candidate = [int(i) for i in str(candidate)]
|
||||||
#print("{}".format(listed_candidate))
|
|
||||||
|
|
||||||
# Determine length of maximum candidate, and manipulate.
|
# Determine length of maximum candidate, and manipulate.
|
||||||
num_digits = listed_candidate.__len__()
|
num_digits = listed_candidate.__len__()
|
||||||
digit_flips = int(num_digits/2)
|
digit_flips = int(num_digits/2)
|
||||||
|
|
||||||
for i in range(1,digit_flips):
|
for i in range(1,digit_flips):
|
||||||
#print("{}".format(i))
|
|
||||||
flipped_candidate[-i-1] = flipped_candidate[i]
|
flipped_candidate[-i-1] = flipped_candidate[i]
|
||||||
flipped_candidate[-1] = flipped_candidate[0]
|
flipped_candidate[-1] = flipped_candidate[0]
|
||||||
|
|
||||||
#print("{}".format(flipped_candidate))
|
# Compare if the flipped version and the original
|
||||||
|
# candidate are identical.
|
||||||
# Compare ...
|
# The function returns this test result...
|
||||||
if listed_candidate == flipped_candidate:
|
if listed_candidate == flipped_candidate:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
@@ -72,17 +66,7 @@ def main():
|
|||||||
# Test for "palindrom-iness" ...
|
# Test for "palindrom-iness" ...
|
||||||
print("{} * {} = {}".format(n,m,n*m))
|
print("{} * {} = {}".format(n,m,n*m))
|
||||||
test_passed = is_palindrome(n*m)
|
test_passed = is_palindrome(n*m)
|
||||||
# if not test_passed and n_has_token:
|
|
||||||
# n -= 1
|
|
||||||
# if n == 1:
|
|
||||||
# n_has_token = False
|
|
||||||
# n = max_factor
|
|
||||||
# elif not test_passed and not n_has_token:
|
|
||||||
# m -= 1
|
|
||||||
# n_has_token = True
|
|
||||||
# else:
|
|
||||||
# palindrome_list.append(n*m)
|
|
||||||
#
|
|
||||||
if test_passed:
|
if test_passed:
|
||||||
palindrome_list.append(n*m)
|
palindrome_list.append(n*m)
|
||||||
if n_has_token:
|
if n_has_token:
|
||||||
|
|||||||
Reference in New Issue
Block a user