+ 2
Can you help me with this code of 2D map problem in Python
from array import * a=array('u',[]) y=[] b=[] c=[] x=input (). split (",") for i in range(len(x)): y.append(list(x[i])) for i in range (len(y)): for j in range (len(y)+1): if y[i][j]=="P": b.append((i)) c.append((j)) d=(b[0]-b[1])+(c[0]-c[1]) print (abs(d))
2 Answers
+ 3
Yes I got it thank you so much
+ 1
# Hi, Puneet Pandey !
# Take a look at this one to see if can help you find your trouble:
s0 = "XPXXX,XXXXX,XXXXX,XXXPX,XXXXX"
s = input() or s0
mk, blk = 'P', 6
p0 = s.find(mk)
p1 = s.find(mk, p0 + 1)
print(abs(p0%blk - p1%blk) + p1//blk - p0//blk if p1 != -1 else 0)