Thursday, September 16, 2010

Learning To Program

I played an educational game that teaches a few fundamental details of programming, and I'm interested to know if I could have written the code more succinctly.
To play it in Ubuntu:
sudo apt-get install laby
Here is my code from the final level:
***
from robot import *;
forward()
left()
while look() == Void:
forward()
if look() == Wall:
right()
while look() == Web:
left()
left()
forward()
forward()
left()
forward()
forward()
left()
while look() == Void:
forward()
if look() == Wall:
right()
while look() == Void:
forward()
escape()

No comments:

Post a Comment