Karel has been hired to build the supports of the Charles Bridge (Karluv most) in Prague. In particular, there are a set of arches where the stones (represented by beepers, of course) are missing from the columns supporting the arches, as follows:

When Karel is done, the missing columns should be replaced by beepers, so the final picture would look like this:

Karel may count on the following facts about the world, listed below:

  • Karel starts at 1st Avenue and 1st Street, facing east.
  • The columns are exactly four squares apart, on 1st, 5th, 9th and 13th Avenue.
  • Karel can assume that columns are always five units high.

Even though the program is only a few lines, it is still worth getting a little practice in decomposition. For example, it would make sense to have a buildColumn method.

For Loops

One thing that computers are really good at is repeating commands.

In general, if you know before hand that there is a block of code you would like to repeat many times you can use a "for" loop, which looks like this:

for(int i = 0; i < N; i++) {
   your code
}
Instead of N you should write the number of times you want your code to be repeated.

For example if you want to move forward ten times, instead of writing the move(); command ten times you could write

for(int i = 0; i < 10; i++) {
   move();
}
See the Place 100 beepers program for another example.

Your program will be much easier to write and easier to read, if you use for loops. There are multiple opportunities to use for loops in this problem!

Good luck and ask questions!