#100DaysOfCode - Day 6

#100DaysOfCode - Day 6

Functions, Code Blocks & While Loops

·

1 min read

Skipping over Functions, I have used them over the last few days, and there is no benefit to chewing over that again. Then code blocks, the various loops, if/elif/else and functions could all be deemed as some block of code.

The tasks for today were all based around a limited command set that could be sent to a robot character to move it around a grid that had a variety of obstacles. The lessons were designed to use the For loop, then progress to using while loops, with the final task to guide the robot through a maze.

For the final task I wrote code, very much like that of the final solution, a final solution that only worked on a fixed set of mazes. I couldn't figure out how to get the robot to turn into... for ease of explanation, a door on the right of a long corridor.

As I knew it was getting close to the time that I had to prepare for my day job. I stopped.
Here is one of the codes I wrote, not the final, let you have the 'joy' of figuring that out.

'''
    https://reeborg.ca/reeborg.html
'''

def turn_right():
    turn_left()
    turn_left()
    turn_left()

def hop():
    move()
    turn_left()
    move()
    turn_right()
    move() 
    turn_right()
    move()
    turn_left()


number_of_hurdles = 6

while number_of_hurdles > 0:
    hop()
    number_of_hurdles -=1