Determine if you are inside or outside a closed region

69 Views Asked by At

You wake up in a desert and you find yourself next to a very, very long wall. All you know is that the wall forms a closed region. You are only allowed to walk in the space, and to put "flags" anywhere in the sand (so you can remember points). How can you determine if you are inside the closed region or outside it?

I have an ugly solution which is hard to present. Anything neat is welcome

1

There are 1 best solutions below

0
On

Follow the wall so that it always stays on your right, and put flags so as to form a polygon approximating the wall. Measure the signed angle you turn while following this polygon until you come back to the first flag you placed.

At the end you will have turned either $+360^\circ$ where counterclockwise is positive, in which case you are inside the wall, or you will have turned $-360^\circ$, in which case you are outside the wall.