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 freeman_lex
def chase(a1_speed, t2_speed, advantage):
'''
When A1 catches T2, it means, they run equal distance.
T2 moves some time t with its speed: Vt * t
A1 moves t-advantage with its speed: Va * (t - advantage)
Vt * t = Va * (t - advantage)
Let's open braces: Vt * t = Va * t - Va * advantage
Move all with t to the right and
with advantage to the left and take
common multiplier out of braces: Va * advantage = t * (Va - Vt)
So, our expression for t is: t = Va * advantage / (Va - Vt)
'''
return a1_speed * advantage/(a1_speed - t2_speed)
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"
Jan. 6, 2023
Comments: