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)

19th May 2021, 5:51 PM
Robert R
Robert R - avatar
2 Respostas
+ 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.
19th May 2021, 6:21 PM
Jan
Jan - avatar
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)
14th Dec 2021, 4:58 PM
Mateo González Bufi
Mateo González Bufi - avatar