Created
May 24, 2018 20:15
-
-
Save sbsatter/5f1947947c43aadeec79d603ec43650d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def nextMove(n,r,c,grid): | |
princess = () | |
for row in range(n): | |
for col in range(len(grid[row])): | |
if grid[row][col] == 'p': | |
princess = (row, col) | |
break | |
m = (r, c) | |
x = princess[0] - m[0] | |
y = princess[1] - m[1] | |
if x != 0: | |
dir = 'DOWN' if x > 0 else 'UP' | |
elif y != 0: | |
dir = 'RIGHT' if y > 0 else 'LEFT' | |
else : | |
print((x, y)) | |
return dir | |
n = int(input()) | |
r,c = [int(i) for i in input().strip().split()] | |
grid = [] | |
for i in range(0, n): | |
grid.append(input()) | |
print(nextMove(n,r,c,grid)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment