Hansel & Ruby -- Due date: In Class, 3/4/2011

Lost in the woods

Ruby has gone out for a long walk in the woods, but, being worried about getting lost, has left a trail of bread crumbs (single coins) behind her. She left 2 coins at her starting point.

There is no coin where Ruby starts, but there is one within one block, either in front, behind, right, or left of her.

The trail will never cross itself, but sometimes Ruby forgets to drop a coin (but never more than one in a row).

Write a Ruby program to follow the trail of bread crumbs home, collect them all, face east, and halt.

How to?

This program is not entirely trivial! Use the problem solving techiques you have learned. Here's how I would simplify the problem.
  1. crumb1.rby has no gaps and no walls -- so, first do the problem with no gaps and no walls!
  2. crumb2.rby has no gaps but has walls -- do this next
  3. crumbWalls.rby has gaps and walls -- and finally, this

The task files

The three files above are in http://www.willamette.edu/~levenick/cs130/examplesFromClass/cs130/ruby/src/ruby/tasks/ with the names above. You should copy them to your tasks directory so you can access them from your simulator.

How to get credit:

Demo on Friday in class.