Learning course: Web development using JavaScript

Problem Link: CodeChef: Practical coding for everyone

### Feedback

def displayPathtoPrincess(n,grid):

princess = []

bot = []

for k,i in enumerate(grid):

if “p” in i:

princess = [i.index(“p”),k]

if “m” in i:

bot = [i.index(“m”),k]

x = princess[0] - bot[0]

y = princess[1] - bot[1]

if x > 0:

for i in range(x):

print(“RIGHT”)

if x < 0:

for i in range(-1*x):
print(“LEFT”)
if y > 0:
for i in range(y):
print(“DOWN”)
if y < 0:
for i in range(-1*y):

print(“UP”)