logo CodeStepByStep logo

UnitedNationsKarel

Language/Type: Java Karel
Related Links:
Author: Mehran Sahami (on 2017/04/10)

Write a Karel program named UnitedNationsKarel with the following behavior. Suppose the United Nations is using Karel to help repair a flood-damaged area. Each robot begins at the west end of a street, and along the street are beepers. Each beeper represents a pile of debris. You should pick up the debris and build a house, centered where the debris was. The houses should look like the figure below to the right. Karel must end up facing east at the southeast corner of the world. Karel should not run into a wall if it builds a house that extends into that final corner. Your solution should work for a world of any size.

Karel may assume the following facts about the world:

  • Karel starts off facing east at (1, 1) with an infinite number beepers in its beeper bag.
  • The initial beepers are spaced so there is room to build houses without overlapping or hitting walls.
screenshot
screenshot
Type your Java solution code here:


This is a class exercise. Submit a complete Java class as described.

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve an exercise or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect tests, etc.), please

Is there a problem? Contact a site administrator.

©, all rights reserved.