Question: Write a program that tasks Karel to pick up a beeper on the current corner, moves to the next corner and picks up the next
Write a program that tasks Karel to pick up a beeper on the current corner, moves to the next corner and picks up the next beeper and so on until Karel reaches a corner where no beeper is located. At that point, Karel faces to theEASTand starts laying the beepers back out in a straight line, one beeper on each corner until he is out of beepers in his beeper bag. This one requires two separate loops, one to pick up the beepers and another one to lay them out.
The rules:
Initially, Karel is facingNORTHon street avenue with NO beepers in his beeper bag.
Start searching for beepers on the corner Karel is initially placed on There may be or beeper on each corner thus Karel may not move at all, nor lay any beepers to the east if the first corner has no beepers on it
After Karel reaches the first corner without a beeper, the first loop terminates, Karel facesEASTandimmediatelystarts placing beepers and places ONLY beeper on each corner as he moves to the East. He continues to place beepers until there are no more beepers in his bag.
No "errorshutoffs."
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
