From 88ad0f92ceb30393c94355438b0bb89ae1310672 Mon Sep 17 00:00:00 2001 From: Mueez Khan <30333942+rzmk@users.noreply.github.com> Date: Fri, 8 Jan 2021 13:58:59 -0500 Subject: [PATCH] Understanding functions and test cases! Can copy/paste code into this URL to try it out: https://reeborg.ca/reeborg.html?lang=en&mode=python&menu=worlds%2Fmenus%2Freeborg_intro_en.json&name=Maze&url=worlds%2Ftutorial_en%2Fmaze1.json Focuses: - Defining and using functions - While loops - PEP8 Indentation styles (4 spaces) - Spaces vs. Tabs --- Day 6/reeborg-maze.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Day 6/reeborg-maze.py diff --git a/Day 6/reeborg-maze.py b/Day 6/reeborg-maze.py new file mode 100644 index 0000000..97adfe3 --- /dev/null +++ b/Day 6/reeborg-maze.py @@ -0,0 +1,17 @@ +def turn_right(): + turn_left() + turn_left() + turn_left() + +while front_is_clear(): + move() +turn_left() + +while not at_goal(): + if right_is_clear(): + turn_right() + move() + elif front_is_clear(): + move() + else: + turn_left()