Block pathing
You are an ant on a childs toy, and would like to find the shortest path between two points. The childs toy simply contains two objects: An axis-aligned rectangle and a circle.
You can assume that:
- The two objects don't overlap
- The two objects don't "kiss" (there is a non-zero distance between the two)
What is the shortest distance from start to finish?
Input
Input will always have the same number of values, all of which are integers, in the following form:
sx sy
ex ey
blx bly trx try
rad cx cy
Where:
sx
andsy
are the x/y coordinates of the starting positionex
andey
are the x/y coordinates of the end goalblx
andbly
are the x/y coordinates of the bottom left corner of the rectangletrx
andtry
are the x/y coordinates of the top right corner of the rectanglerad
is the radius of the circlecx
andcy
are the x/y coordinates of the centre of the circle
Output
Output a single value representing the shortest distance from the start to end goal. Any answer with absolute or relative error of will be considered correct.
Example
Take the following input:
1 1
14 14
2 2 7 7
4 11 11
This is represented by the following graph:
Which can be pathed in the following manner:
Resulting in a distance of
21.625015745078453
Constraints
- All values given are in the range
Comments
Fun problem, highly recommend this for beginners! :D
It's okay to cry, you were not made that strong.