Last active
December 17, 2015 00:38
-
-
Save jamiees2/5522011 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
#!/bin/python | |
# Head ends here | |
def nextMove(n,y,x,grid): | |
princessX, princessY = findInArray('p',n,grid) | |
if princessY > y: | |
return "DOWN" | |
elif y > princessY: | |
return "UP" | |
if x > princessX: | |
return "LEFT" | |
elif princessX > x: | |
return "RIGHT" | |
def findInArray(s, n, arr): | |
for i in xrange(len(arr)): | |
for j in xrange(n): | |
if arr[i][j] == s: | |
return (j,i) | |
# Tail starts here | |
n = input() | |
x,y = [int(i) for i in raw_input().strip().split()] | |
grid = [] | |
for i in xrange(0, n): | |
grid.append(raw_input()) | |
print nextMove(n,x,y,grid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment