Reeborgs World The Hurdles Loop Challenge
def jump():
move()
turn_left()
move()
turn_right()
move()
turn_right()
move()
turn_left()
def turn_right():
turn_left()
turn_left()
turn_left()
for step in range(6):
jump()
Reeborgs World Hurdle 2 - while function
def jump():
move()
turn_left()
move()
turn_right()
move()
turn_right()
move()
turn_left()
def turn_right():
turn_left()
turn_left()
turn_left()
while not at_goal():
jump()
Reeborgs World - Hurdle 3
def turn_right():
turn_left()
turn_left()
turn_left()
def jump():
turn_left()
move()
turn_right()
move()
turn_right()
move()
turn_left()
while not at_goal():
if wall_in_front():
jump()
else:
move()
Reborgs World - Hurdle 4
def turn_right():
turn_left()
turn_left()
turn_left()
def jump():
turn_left()
while wall_on_right():
move()
turn_right()
move()
turn_right()
while front_is_clear():
move()
turn_left()
while not at_goal():
if wall_in_front():
jump()
else:
move()
Project 6 - Reeborgs Maze
def turn_right():
turn_left()
turn_left()
turn_left()
while front_is_clear():
move()
turn_left()
while not at_goal():
if front_is_clear() and wall_on_right():
move()
elif front_is_clear and right_is_clear():
turn_right()
move()
elif front_is_clear():
move()
elif wall_in_front and right_is_clear():
turn_right()
move()
else:
turn_left()
Note: As a beginner this was really hard for me. The instructions were that if I couldn't solve the problem then to leave this and wait until day 15 lessons then come back and do it again. I didn't listen lol and kept going to solve it. It took me a few hours of googling then understanding why the code had to be written this way. I ran the code a few times for testing and it worked, but will run it more as the maze changes every time.
Top comments (0)