Spidey Distance
Jump to navigation
Jump to search
This problem defines two measures of grid distance and asks us what the fraction of overlap is.
The first thing to note is we only need to observe one quadrant, and it doesn't change the answer, as both measures are 4-way symmetric. Second, we note that the distance is only 10^6, so it is relatively small. Lastly, given an X value, we can closed-form compute the Y value for both manhattan distance. They are, both from observation:
- y=taxi-x
- y=(spidey-1.5x)+x=spidy-.5x, when x < spidey/1.5, or y=2(spidey-x) otherwise
We can iterate through quadrant I, and evaluate for each value of X what is the value of Y for taxi distance, and the minimum value for taxi and spidey. We sum these up for all the columns, and then divide them by the greatest common demoninator, found by euler's method, to reduce the fraction.