# The vicious wizard…and you!

The vicious wizard Neville has trapped you in the middle of a magical circle of radius $10000$, and you have to find a way out.
Every time you want to take a step (of length $1$) in a certain direction, Neville decides whether you move in that direction or the opposite one.
Of course, the wizard does his best to hinder you, not to let you escape!
This is an example: Is there a strategy to escape? If so, how long is the path to freedom?

• You could make it a radius $100$ and not lose the puzzle but, at one step / second, it would be escapable in a littler under 3 hours instead of a little over 3 years. It is a vicious wizard, though. Also, if your steps are the average human step of 2.5 feet, then the circle is 9.5 miles or 15.2 kilometers in diameter. Who has that much free space to make circles? – Engineer Toast Jun 12 '15 at 14:03
• @EngineerToast You can use any positive integer (with real the final step gets "tricky") and the problem is the same. The important thing isn't the number of days, it's just the strategy :) – leoll2 Jun 12 '15 at 14:11
• Well, any positive integer greater than 1 ;) The suggestion was just to preclude caveats like "better bring your +3 Bag of Food" – Engineer Toast Jun 12 '15 at 14:46
• @EngineerToast Sometimes a bit of trills are funny, not that negative. – leoll2 Jun 12 '15 at 14:53

Yes, there is a strategy to escape! Imagine a circle centred at your original location and extending to your current location. Move tangent to it; the opposite direction will also be tangent to it, and both will be farther from the middle than where you started. After $n$ steps, you’re $\sqrt n$ steps away from the middle and can make it out in 100000000 steps. Lots of walking ahead!

• Ah, that solves the distance. That was not that hard :( – Mathias711 Jun 11 '15 at 7:09
• Image would be useful for clarification. The initial position is random in the circle (I assume). So what is the first direction you go to? i.e. what do you specify as "original" and what as "current" location in this first step? And in the next step? If I'm not mistaken the "original" position should always be the centre of the circle, shouldn't it? – BmyGuest Jun 11 '15 at 9:34
• @BmyGuest Yes, you start in the centre. – leoll2 Jun 11 '15 at 10:18
• This is the correct answer! I also appreciate BmyGuest's explanation, detailed and complete, he deserves an upvote! – leoll2 Jun 11 '15 at 12:01
• @BmyGuest: When the circle is of size zero (you’re at the original location), every direction is tangent to it, so pick any one. – Ry- Jun 11 '15 at 15:25

To escape you need a magical rucksack, but it is theoretically possible.

Always walk tangential to a circle centred at the magical circle's origin with a radius to your current position. It does not matter if the mage choses the "red" or the "green" step as far as distance from the centre is concerned.

If $s$ is your step-length (arrow length) and $r$ (yellow) your current distance from the centre, then each step takes you $\sqrt{r^2 + s^2}- r$ closer to the border. In other words:

Starting from the centre, after the first step you are $s$ away from the centre, after $2$ steps it is $\sqrt{2} s$, after $3$ steps it is $\sqrt{3} s$, .... after $n$ step it is $\sqrt{n} s$.
If you need to get $x$ steps in distance, you need $x^2$ steps to take, or $10000\times10000$ for this circle. If you're constantly waking with one step per second and assume that you can walk for no more than $16$ hours without resting, you have $1736$ days to go - and hopefully a very good rucksack of infinite supplies...

• No problem! I hope it's easier to read now – leoll2 Jun 12 '15 at 13:59

There certainly is a way to the border. Every step you should construct the shortest line that intersect the circle at two points, and your current position. Then you take a step on that line. It doesn't matter in what way Neville sends you, because it is symmetric. However, every step is closer to the border then you were before.

The (possible) distance:

I do not know. There probably is some mathematical formula, but I'm currently too busy. I think a possible solution is spiralling outwards.