CS111 2010

Some guidance on solving the lab rug problem

Here are two strategies for solving the lab rug program.

Strategy I: From the outside in

We'll call the first one "from-the-outside-in". You can view the rug as a series of 3 concentric patterns, like this (where the pattern to focus on is shown in blue highlight):

The outermost pattern (the red bagelled border):

The middle pattern (the blue bagelled pattern):

The center (the yellow bagelled pattern -- looks like the number 5 on a die):

Strategy II: Quadrants

Alternatively, you can view the rug as the same quadrant repeated 4 times. Here is the pattern:

If you can write a method to draw the lower left corner of the rug, then all you have to do is move your buggle to each successive corner, and call that method. Four calls to the same method will produce the entire rug. Wow.

Back to the Lab 2 webpage