Iterative Refinement, cont.
Refinement B (using #rooms distance)
/* There are n2 rooms arranged in an n-by-n grid. Some adjacent rooms have connecting doors. No doors lead outside. You are in the upper-leftmost room facing left. A sequence of doors leads to the lower-rightmost room. Get there. */
while ( you are not in lower rightmost room )
/* Get at least one room “closer” to
while (you are not facing a door)
Turn 90 degrees clockwise;
Turn 90 degrees counter-clockwise;