Created
May 28, 2020 23:57
-
-
Save jluismm2311/b5ab4c28dad452474bda9747c046887f to your computer and use it in GitHub Desktop.
Two tortoises named A and B must run a race. A starts with an average speed of 720 feet per hour. Young B knows she runs faster than A, and furthermore has not finished her cabbage. When she starts, at last, she can see that A has a 70 feet lead but B's speed is 850 feet per hour. How long will it take B to catch A? More generally: given two spe…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Tortoise { | |
public static int[] race(int v1, int v2, int g) { | |
if (v1 >= v2) | |
return null | |
def averageTime = (g*3600).intdiv(v2-v1) | |
[averageTime.intdiv(3600), averageTime.mod(3600).intdiv(60), averageTime.mod(3600).mod(60)] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment