# Can you help the traveller

A traveller decided to explore a square desert. He started from a point on the edge to point B, travelling perpendicular to the edge of the desert he started on. On reaching B, he then decided to take a 90 degree turn to travel to point C, where he spent the night.

The next day he was told that he could go straight and reach point D, take a 90 degree turn towards the starting point turn and reach point F (which were both on the edge of the desert), or go to a A which was further interior in the desert - which would require him to travel at an unknown angle. He chose to travel to A.

After spending another night at A, He retreated to his original starting point by day end. Though he did not intend to, he passed through point B before reaching his final destination.

He was then amazed to find that he had travelled the same distance in the last two days, and the distance covered by each of those two day's travels was a whole prime number.

He also concluded the following from his records

1. The distances he had travelled from A to B and from B to C added up to the next prime number (to the prime number he estimated to have travelled in each of the last two days)

2. When he decided to retreat he was equally far from all the corners of the desert

3. All his travels were in perfect straight lines, the only turns he took where when he travelled from point B to C and C to A and A to his starting point.

4. He noticed that the distance he travelled from A to B was significantly shorter than his travel from B to C

He was wondering if he could find out how far he was from D and F when he decided to travel to A - can you help him?

As you may have realised by now, I made this up, so if you think I am missing something add in comments.

Edit: There are two possible values after my last edit and one of them is captured, but not the other, so I have accepted the answer with one of them now, but will upvote anyone coming up with both

• what do you mean by this? "and in miles it was a whole prime number." the distance he had gone from start point or total travel path?
– Rafe
Oct 18, 2014 at 8:33
• Those two travels that he made in the last two days (which he found to be equidistant), each were prime numbers, not the whole distance
– skv
Oct 18, 2014 at 8:42
• great question skv. Oct 18, 2014 at 12:09

Lets simplify the travelling path:

• The Traveler starts from somewhere on the edge ($Start$ point)
• He goes perpendicular to edge to point $B$
• He takes 90 degree turn (either clockwise or counter-clockwise) to point $C$ or $C'$ and spend the night
• He travels with unknown angle to point $A$ and spend the night again (Which we can conclude that $A$ is the center of desert from his 2nd record)
• He came back to where he was started ($Start$ point)

The traveler traveled straight and from $A$ to $Start$ through $B$ so also $Start$-$B$ was perpendicular to edge, So $Start$ was in center of it's edge. It was not clarified that traveler traveled to his left or right at 90 degree turns so it creates some other possible paths. (all have been drawn below) There is a right triangle, So we can say:

• $A$-$B + B$-$C > A$-$C$
• $(A$-$B)^2 + (B$-$C)^2 = (A$-$C)^2$
• $A$-$B < A$-$C$ and $B$-$C < A$-$C$

We also know:

• $C$-$A = A$-$Start$ are primes in mile.
• $A$-$B + B$-$C$ is the next prime number to $A$-$C$ (from first record)
• $B$-$C > A$-$B$ (from 4th record)

So (for minimizing the travel distance,) it came that:

• $A$-$C = 5$
• $B$-$C = 4$
• $A$-$B = 3$

At point C, The traveler should be in $1$ mile distance of point $D$ and $2$ or $8$ miles from point F. (it depends which side would he choose to turn - clockwise or counter-clockwise)

You can see the numbers below: • Sorry, I changed back the 25 miles condition, which is not necessary
– skv
Oct 18, 2014 at 9:23
• Good to hear :-) BTW, creative question. +1
– Rafe
Oct 18, 2014 at 9:31
• Thanks, and a great answer, now can you just think if the 25 mile condition can be made
– skv
Oct 18, 2014 at 10:29
• And frankly did not expect an answer so quick :) great job
– skv
Oct 18, 2014 at 10:30
• one quick answer is to double all the values, but I will check for float numbers less than the double as soon as I came back from work
– Rafe
Oct 18, 2014 at 10:44

Let's say distance $AC = x, BC = y, AB = z$.

Then, x is prime p, y + z = q, the next prime.

$y^2+z^2=p^2$

$(y+z)^2=q^2=y^2+z^2+2yz$

$2yz=q^2-p^2$

Using $y=q-z$

$2(q-z)z=q^2-p^2$

Giving $z^2-qz+\frac{q^2-p^2}{2}=0$

Which has real roots when

$q^2 \geq 4\frac{q^2-p^2}{2}$

Which reduces to

$q \leq \sqrt{2}p$

And gives $y,z = \frac{q\pm \sqrt{2p^2-q^2}}{2}$

This rules out $p,q=7,11$ as a pair. $p,q=11,13$ satisfies our condition, and gives $y,z=\frac{13\pm \sqrt{73}}{2}$.

I assume you were looking for the rather nicer pair of $p,q=13,17$ giving $y,z = 5,12$.

Whatever values we get for x,y,z, the distances to F and D are given by $D=z-y, F=z\pm x$ (this is shown quite nicely in Rafe's answer) For the specific example of $p,q=13,17$ D is 1 and F is 8 or 18, though you can generate arbitrary numbers of solutions.

Edit: I missed the change stating that F is on the same side as the start point. This removes the larger value for F from all solutions.

Edit 2: typo