-
Notifications
You must be signed in to change notification settings - Fork 1
/
PuzzleKarel.py
57 lines (43 loc) · 980 Bytes
/
PuzzleKarel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from karel.stanfordkarel import *
"""
File: PuzzleKarel.py
--------------------
Karel should finish the puzzle by picking up the last beeper (puzzle piece) and placing it in the right spot.
Karel should end in the same position Karel starts in -- the bottom left corner of the world.
"""
def main():
"""
pick up the last beeper and place it in the right spot
"""
picking_beeper()
complete_puzzle()
return_back()
def picking_beeper():
move()
move()
pick_beeper()
def complete_puzzle():
move()
turn_left()
move()
move()
put_beeper()
def return_back():
turn_around()
move()
move()
turn_right()
move()
move()
move()
turn_left()
turn_left()
def turn_right():
for i in range(3):
turn_left()
def turn_around():
for i in range(2):
turn_left()
# There is no need to edit code beyond this point
if __name__ == "__main__":
run_karel_program('Puzzle.w')