-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTripleKarel.py
More file actions
36 lines (28 loc) · 921 Bytes
/
TripleKarel.py
File metadata and controls
36 lines (28 loc) · 921 Bytes
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
from karel.stanfordkarel import *
"""Paints all 3 houses in any world
Pre: Karel starts facing west at the upper right corner of the leftmost building
Post: Karel finished painting all 3 houses and facing west past left corner of
the rightmost building"""
def main ():
for i in range(3):
paint_house()
""" Karel paints 3 walls of the house and moves to the next house if there is one"""
def paint_house():
for i in range(2):
paint_one_wall()
turn_left()
move()
paint_one_wall()
if front_is_blocked():
turn_right()
""" Makes Karel move to the end of the wall, dropping a beeper before each step it takes"""
def paint_one_wall():
while left_is_blocked():
put_beeper()
move()
def turn_right():
for i in range (3):
turn_left()
# There is no need to edit code beyond this point
if __name__ == "__main__":
run_karel_program()