Home
Run/Edit Program
Edit World
Save/Restore World
Tutorials
Sample Programs
Language Reference

Sample Programs

To restore a program and world below, click on the appropriate links below and copy the text( Windows - ctrl A followed by ctrl C to copy. MAC - cmd A followed by cmd C to copy. ) . Paste the text according to the steps in Restoring Worlds tutorial.

Pick Up Newpaper

Task: Karel lies in bed. He needs to go outside and retrieve the newspaper. Then he should come back inside and get in bed facing the same direction.

Newspaper Program

Newspaper World

Pick Up Newpaper - Simplified

Task: The task is the same as for the prior sample program. The difference is this task defines new instructions to simplify the program.

Newspaper Program

Newspaper World

Pick Up Beeper Rectangle

Task: Pick up an rectangular array of beepers with any number of rows and columns. Karel is on the southwest corner of the beeper rectangle facing north.

Rectangle Program

Rectangle World

Move Through the Tunnel

Task: Move Karel through the tunnel and exit the other end. As soon as Karel exits, he should shut down.

Tunnel Program

Tunnel World

Climb the Stairs

Task: Karel climbs the stairs until he reaches the top. A new instruction is defined to help simplify the task.

Climb Stairs Program

Climb Stairs World

Bowling Pins Problem - Simplicity

Task: Karel sets up the bowling pins in an alley. This program takes a simple top down approach. However it is not the most efficient

Bowling Pins Program

Bowling Pins World

Bowling Pins Problem - Efficiency

Task: Karel sets up the bowling pins in an alley. This program takes an efficient top down approach. It takes almost 20% less time than the previous Bowling Pins example. However, the code is slightly more complicated.

Bowling Pins Program

Bowling Pins World