Can you help me with this code of 2D map problem in Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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))

22nd Nov 2022, 5:14 AM
Puneet Pandey
Puneet Pandey - avatar
2 Answers
+ 3
Yes I got it thank you so much
22nd Nov 2022, 6:06 AM
Puneet Pandey
Puneet Pandey - avatar
+ 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)
22nd Nov 2022, 6:00 AM
Per Bratthammar
Per Bratthammar - avatar