09-Section-Handout - The correct solution for a 3x3 square...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS106A Handout 09 Spring 2011 April 4 th , 2011 Section Handout Problem 1: Karel the Robot [courtesy of Steve Cooper] We want to write a Karel program which will create an inside border around the world. Each location that is part of the border should have one (and only one) beeper on it and the border should be inset by one square from the outer walls of the world like this: In solving this problem, you can count on the following facts about the world: You may assume that the world is at least 3x3 squares.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: The correct solution for a 3x3 square world is to place a single beeper in the center square. • Karel starts off facing East at the corner of 1 st Street and 1 st Avenue with an infinite number beepers in its beeper bag. • We do not care about Karel’s final location or orientation. • You do not need to worry about efficiency. • You are limited to the instructions in the Karel reader—the only variables allowed are loop control variables used within the control section of the for loop....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online