0
2D Map 4th test case failed
Been trying to solve this challenge for a few hours and it always shows 4th test case wrong. maps = input() x = maps.replace(",","") place = [] steps = 1 place.append(x.index("P") % 5) place.append(x.rindex("P") % 5) steps += (place[1] + 1) - (place[0]+1) for i in range(x.index("P"),x.rindex("P")+1,5): steps += 1 print(steps-2)
2 odpowiedzi
+ 1
With that task, you can actually test all possible combinations before submitting it to the test cases.
I think you should do that to find out what combination you have missed, that fails the number of steps.
0
import numpy as np
map = input().split(',')
matrix = [list(map[i]) for i in range(len(map))]
a = np.array(matrix)
b = np.where(a=='P')
x2, x1, y2, y1 = b[0][1],b[0][0],b[1][1],b[1][0]
dist = abs(x2 - x1) + abs(y2 - y1)
print(dist)