[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

860.0. "A problem from Stan Rabinowitz" by SSDEVO::LARY () Fri Apr 08 1988 23:39

+-+-+-+		A Mad Mathematician has taken an infinite sheet of graph paper
|     |		and, starting at the origin going towards (0,1), has drawn a
+ +-+ +		"space-filling clockwise spiral" that occupies all the lattice
|   | |		points.
+-+-+ +
			

A-B-C-A		The MM then labeled these lattice points cyclically with the
|     |		labels A, B, and C, starting at the origin and following the
C A-B B		path of the spiral. The MM then erased the spiral, leaving
|   | |		only the labeled lattice points.
B-A-C C

You are dropped at a random place on this sheet. Find the origin.

T.RTitleUserPersonal
Name
DateLines
860.1Off the top of my head...AKQJ10::YARBROUGHWhy is computing so labor intensive?Mon Apr 11 1988 13:3211
Let me try an intuition: from any given starting place, pick a direction 
and move in that direction as long as the sequence ...c,b,a,c... appears.
When something out of sequence would appear, turn left instead. This should
get you going in the right direction after at most 3 wrong directions, and 
take you to the starting point, from where you can calculate the original 
position.

An illusory sequence might occur in a place where the original path turns 
left, but a letter in correct sequence appears ahead, on an outer turn of 
the spiral. What needs to be proven is that no illusory sequences actually
occur (else my algorithm will loop). 
860.2CADM::ROTHIf you plant ice you'll harvest windMon Apr 11 1988 15:576
    This is suspiciously reminiscant of Stan's plot of primes in a spiral.

    A plot of the vertices as colored points on a raster will probably look
    nice...

    - Jim
860.3CADM::ROTHIf you plant ice you'll harvest windMon Apr 11 1988 18:5136
    Suppose you colored lattice squares Red, Green, Blue in the
    spiral pattern (which is what I would do for making a picture.)

    This results in a symmetric pattern with four 'quadrants'
    separated by diagonals passing thru the origin like this:

           \ ..BGRBGR  /
	    \..BGRBGR /
	     \       / ..
	      \     /  ..
	  RR   \   /   BB
	  GG    GRB    GG
	  BB    BRG    RR
	  RR    R \    BB
	  GG   /   \   GG
	  BB  /     \  RR
	  .. /       \
	  ../ RGBRGB..\
           /  RGBRGB.. \

    Note that in each quadrant, there will be double strips of RGB colors as
    shown.

    Barring landing on a diagonal or too near the center, you can tell
    something about your location and orientation by looking for vertical
    or horizontal RGB patterns from where you currently are.  Then the idea
    could be to follow the RGB strip until you hit a diagonal, which breaks
    the symmetry of the repeating colors.

    One way to find the origin would be to look for the diagonal in each
    direction and then use dead reckoning.  It shouldn't be necessary to
    actually follow the RGB patterns all the way in along a spiral path.

    [I made the spiral above CCW by mistake, sorry about that.]

    - Jim
860.4POOL::HALLYBYou have the right to remain silent.Mon Apr 11 1988 19:567
>    One way to find the origin would be to look for the diagonal in each
>    direction and then use dead reckoning.  It shouldn't be necessary to
>    actually follow the RGB patterns all the way in along a spiral path.

    Do I hear a contest in the offing?  You move 1 square any direction
    and some magic software tells you your surroundings and keeps count
    of how many moves you have made...
860.6no neighbour with same letter? Left at fork!HERON::BUCHANANprocrastinated lazinessTue Apr 12 1988 12:3337
     Surprising!

     Whatever cell you're in, you examine its letter, and that of the 4 
neighbouring cells, and you can immediately answer the following questions:

     (1) am I at the origin already?
     (2) if the answer to (1) is "No", which of the 4 neighbours is the 
predecessor on the spiral to the cell I'm currently in?

     So by iterating on this, I cannot fail to trace back along the spiral to
the origin.

*

     Here's what you do.   Find out which of the following maps corresponds to
the particular position you are in (you may have to rotate the map, reflect 
the map, or cyclically permute the symbols ABC to find the one that matches).

     Then you decide which way to go, knowing that for the particular maps I've
shown, the correct direction to go is WEST.

 C            B            A            B            C
ABC          ABC          ABC          ABA          ABB
 C            A            C            C            C 

     Suppose none of these five maps is applicable?   Well, then you're at the
origin already.

*

     To summarize: when you have a choice between going straight on, and
turning left, go straight IFF one of the adjacent cells is the same letter as
the cell you're on.

*

Does Stan the Man have any more interesting problems?
860.7Mad Mathematician, part IICLT::GILBERTTue Apr 12 1988 20:553
    The Mad Mathematician was always a bit overzealous.  Instead of
    simply erasing the spiral, he also erased all the 'b's and 'c's!
    Was Dylan right?  Can you go home?
860.8Mad Mathematician, part IIISTAR::HALLYBKnight-errant says "CI!" Tue Apr 12 1988 21:274
    The Mad Mathematician was always a bit confused.  He laid down a
    spiral with some fixed number of symbols A, B, C, E, F, ... but
    you weren't told how many.  Was Gilbert right when he asked:
    Was Dylan right?  Can you go home?
860.9Getting there quickerSSDEVO::LARYTue Apr 12 1988 21:4815
Some of the replies have mentioned ways to trace back along the spiral;
given any one of those methods, it seems that you can get to the origin a lot
faster with the following modification:

1)	Use the algorithm to figure out the way back along the spiral

2)	Move one unit in that direction, and then (if you are not at
	the origin) take a left and move one unit.

3)	Iterate until you hit the origin

The modified algorithm approaches the origin by approximating a spiral that
is inclined 45 degrees to the radius vector, as opposed to the almost-90
degree spiral that the MM drew....

860.10a little simpler...SSDEVO::LARYTue Apr 12 1988 21:536
Step 2 of .-1 can be simplified to "Facing that direction, move one unit to
your left". I was being too scared of corners.

(Presumably, corners can be identified and an even faster method that allows
diagonal moves could be derived...)

860.11CADM::ROTHIf you plant ice you'll harvest windWed Apr 13 1988 19:2013
    If you're away from the diagonals the plane is tiled with 3 by 3 squares
    that are reflections of each other about their diagonals (depending
    on which quadrant you're in.)

    This means that the best you can do in the midst of these squares is
    move toward a diagonal until you hit it.

    Then on the diagonal you could track it in toward the origin.

    Isn't one of the prior replies an exhaustive case analysis of where to
    go given your current location?

    - Jim
860.12Optimal algorithm without diagonalsCLT::GILBERTWed Apr 13 1988 20:4351
Suppose you don't know your orientation, and you can 'see' your square and
the four adjacent squares.  Then, if three values in a row (column) are
different, then a particular direction is 'indicated'.  For example, in:

	   ?                  ^
	a  c  b,   a movement | (that way) is 'indicated', since the 'abc'
	   ?                  |

pattern seems to correspond to the pattern 'above' the origin (e.g. the pattern:

	a  c  b  a  c  b
	a  c  b  a  c  b ... ).  Two directions may be 'indicated', for example,
	c  b  a  c  b  a

	   b          ^
in:	a  c  b, both | and <-- are 'indicated'.
	   a          |


Through case analysis, we formulate the following rules:

If one direction is 'indicated', go in that direction.  If two directions are
'indicated', we are on a diagonal, and the origin is in the direction that
combines the two 'indications'.  If no direction is 'indicated', we have one
of the following 5 cases:

	   b
	c  a  b,	we are at the origin;
	   a

	   a         b         c
	b  a  b,  c  c  a,  a  a  b,	the origin is SE (southeast);
	   c         b         c

	   c
	a  b  b,	the origin is either SW or W (and it's W iff
	   c		we're one square from the origin).

Assuming that we can move to only one of the four adjacent squares, the
above rules can be further distilled:

	If some direction is 'indicated', move in that direction.
	(if more than one direction is 'indicated', choose either one).

	If no direction is 'indicated', face away from the square that
	contains the same symbol as the square you're on.  If the left-
	and right-hand squares have different symbols, you're at the
	origin.  Otherwise, step forward.
	    
When repeated, this gives a minimal path to the origin, assuming that
diagonal moves are not allowed.