From dbc251f7e348819dda1f9c8d348aa5b39c92d59d Mon Sep 17 00:00:00 2001 From: Shaun Setlock Date: Mon, 20 Apr 2020 14:21:51 -0400 Subject: [PATCH] Automatic commit performed through alias... --- problems/004_problem.py | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/problems/004_problem.py b/problems/004_problem.py index 8375f90..26d8c37 100755 --- a/problems/004_problem.py +++ b/problems/004_problem.py @@ -13,10 +13,6 @@ import decorators import time -# Create function that finds the next -# prime number when supplied with an -# intitial integer. - def is_palindrome(candidate): """ Returns a boolean to confirm if the passed @@ -31,20 +27,18 @@ def is_palindrome(candidate): # Convert maximum candidate to a list ... listed_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. num_digits = listed_candidate.__len__() digit_flips = int(num_digits/2) for i in range(1,digit_flips): - #print("{}".format(i)) flipped_candidate[-i-1] = flipped_candidate[i] flipped_candidate[-1] = flipped_candidate[0] - #print("{}".format(flipped_candidate)) - - # Compare ... + # Compare if the flipped version and the original + # candidate are identical. + # The function returns this test result... if listed_candidate == flipped_candidate: return True else: @@ -72,17 +66,7 @@ def main(): # Test for "palindrom-iness" ... print("{} * {} = {}".format(n,m,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: palindrome_list.append(n*m) if n_has_token: