From eab5b7d09848980e3a4a40c6962fe3e495c215ff Mon Sep 17 00:00:00 2001 From: Shaun Setlock Date: Mon, 20 Apr 2020 15:41:52 -0400 Subject: [PATCH] Automatic commit performed through alias... --- problems/005_problem.py | 46 ++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/problems/005_problem.py b/problems/005_problem.py index 0157088..b9b9e28 100755 --- a/problems/005_problem.py +++ b/problems/005_problem.py @@ -13,23 +13,55 @@ import decorators # Typically imported to compute execution duration of functions. import time # Typically imported for sleep function, to slow down execution in terminal. +import typing -def compute_modulus(divisor,dividend): +def evenly_divisible(candidate: int,factors: list): """ - Returns modulus of two passed integers. + Determines if the supplied integer candidate is + evenly divisble by the supplied list of factors. - is_palindrome(divisor, dividend) + evenly_divisible(candidate: int, factors: list) - param 'divisor': Integer to be divided by dividend. - param 'dividend': Integer dividing the divisor. + param 'candidate': Integer to be tested. + param 'factors': List of factors for the modulus operator. """ - pass + + modulus_sum = 0 + + for n in factors: + modulus_sum += candidate%n + + if modulus_sum == 0: + return True + else: + return False @decorators.function_timer def main(): - print("The largest palindrome number which is a product of two numbers of length {} is {} ... ".format("foo","foo")) + # Receive problem inputs... + smallest_factor = 1 + largest_factor = 17 + + # Compute intermediate inputs + factor_list = [int(i) for i in range(smallest_factor,largest_factor+1)] + maximum_solution_bound = 1 + for f in factor_list: + maximum_solution_bound *= f + + # Initialize loop parameters + n = 10 + test_passed = False + + while n