-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBotClean
More file actions
41 lines (36 loc) · 1.13 KB
/
BotClean
File metadata and controls
41 lines (36 loc) · 1.13 KB
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
#!/usr/bin/python3
# Head ends here
def next_move(posr, posc, board):
if board[posr][posc] == 'd':
print('CLEAN')
return
if posr > 0 and board[posr-1][posc] == 'd':
print('UP')
return
elif posr < len(board)-1 and board[posr+1][posc] == 'd':
print('DOWN')
return
elif posc > 0 and board[posr][posc-1] == 'd':
print('LEFT')
return
elif posc < len(board)-1 and board[posr][posc+1] == 'd':
print('RIGHT')
return
else:
for i in range(len(board)):
for j in range(len(board)):
if board[i][j] == 'd':
if i > posr:
print('DOWN')
elif i < posr:
print('UP')
elif j > posc:
print('RIGHT')
elif j < posc:
print('LEFT')
return
# Tail starts here
if __name__ == "__main__":
pos = [int(i) for i in input().strip().split()]
board = [[j for j in input().strip()] for i in range(5)]
next_move(pos[0], pos[1], board)