-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewsdoll.py
21 lines (21 loc) · 1023 Bytes
/
newsdoll.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""News Doll"""
def main():
"""บอกที่เริ่มและทิศที่จะไป"""
place = int(input())
drive = input().capitalize()
move(place, drive)
def move(place, drive):
"""เก็บค่าตำแหน่งที่อยู่"""
if drive == "Stop":
print(place)
elif place == 1 and (drive == "East" or drive == "South"):
move(((2 * (drive == "East")) + (3 * (drive == "South"))), input().capitalize())
elif place == 2 and (drive == "West" or drive == "South"):
move(((1 * (drive == "West")) + (4 * (drive == "South"))), input().capitalize())
elif place == 3 and (drive == "East" or drive == "North"):
move(((4 * (drive == "East")) + (1 * (drive == "North"))), input().capitalize())
elif place == 4 and (drive == "West" or drive == "North"):
move(((3 * (drive == "West")) + (2 * (drive == "North"))), input().capitalize())
else:
move(place, input().capitalize())
main()