Automatic commit performed through alias...
This commit is contained in:
@@ -13,23 +13,55 @@
|
|||||||
|
|
||||||
import decorators # Typically imported to compute execution duration of functions.
|
import decorators # Typically imported to compute execution duration of functions.
|
||||||
import time # Typically imported for sleep function, to slow down execution in terminal.
|
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 'candidate': Integer to be tested.
|
||||||
param 'dividend': Integer dividing the divisor.
|
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
|
@decorators.function_timer
|
||||||
def main():
|
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<maximum_solution_bound and not test_passed:
|
||||||
|
test_passed = evenly_divisible(n,factor_list)
|
||||||
|
if not test_passed:
|
||||||
|
n += 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print("The largest palindrome number which is a product of two numbers of length {} is {} ... ".format(factor_list,n))
|
||||||
|
|
||||||
main()
|
main()
|
||||||
Reference in New Issue
Block a user