Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def findDirtySpots(board):
- return [(x.index('d'), i) for i, x in enumerate(board) if 'd' in x]
- def closest_Spot(x, y, spots):
- spot_dist = [(i, j, abs(i - x) + abs(j - y)) for (i,j) in spots]
- return (min(spot_dist, key = lambda t: t[2]))[0:2]
- def next_move(posr, posc, board):
- dirtySpots = findDirtySpots(board)
- c_x, c_y = closest_Spot(posc, posr, dirtySpots)
- if c_x == posc and c_y == posr:
- print("CLEAN")
- elif c_x == posc:
- print("UP" if c_y < posr else "DOWN")
- else:
- print("LEFT" if c_x < posc else "RIGHT")
- # 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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement