mfb
Mentor
- 37,391
- 14,221
There is no need to check both sides.Verdict said:What I did was prove that the distance between the two rocks is 2 times as large as the distance from the middle point of the two rocks to the treasure. I then showed that the dot product of the direction vector of the line connecting the two rocks with the direction vector of the middle point of the two rocks to the treasure is 0, which means that they are orthogonal. So just measure the distance between the rocks, walk halfway, and turn 90 degrees to either left or right, move the measured distance and dig. If its not there, go to the other side instead, and there it is!
Here is my solution:
With the tree as origin and rock positions r and R, A=(1+i)*r and B=(1-i)*R.
Therefore, the treasure is at (A+B)/2 = r*(1+i)/2 + R(1-i)/2.
If you shift the tree by an amount -x, this is equivalent to shifting both rocks by x, and the treasure is located at (r+X)(1+i)/2 + (R+x)(1-i)/2 = (A+B)/2 + x. Therefore, the treasure is shifted by the same amount as the rocks, and the tree position does not matter for their relative orientation. Choose R as tree position, and the location of the treasure is easy to get (45° to the left of the direction to r, with 1/sqrt(2) its distance).