Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Achilles and the Tortoise by colinmcnicholl
def chase(a1_speed, t2_speed, advantage):
"""input: Three arguments. Speeds of A1 and T2 and advantage as integers.
output: The time when A1 catch up T2 (count from T2 start) as an integer or float.
"""
secs_from_a1_start = t2_speed * advantage / (a1_speed - t2_speed)
return round((advantage + secs_from_a1_start), 8)
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
def almost_equal(checked, correct, significant_digits):
precision = 0.1 ** significant_digits
return correct - precision < checked < correct + precision
assert almost_equal(chase(6, 3, 2), 4, 8), "example"
assert almost_equal(chase(10, 1, 10), 11.111111111, 8), "long number"
Sept. 9, 2017