def turn_right(): repeat(turn_left, 3) # To move up the hurdle, move # until the right is clear (as # long as the right is not clear). def up_hurdle(): turn_left() while not right_is_clear(): move() turn_right() # To move down the hurdle, move # as long as the front is clear. def down_hurdle(): turn_right() while front_is_clear(): move() turn_left() # Making one step forward either # means just moving forward or # going up a hurdle, then moving # over and then moving down the # hurdle. def one_step(): if front_is_clear(): move() else: up_hurdle() move() down_hurdle() # Make one step forward 9 times. repeat(one_step, 9) turn_off()