+ 2

# 2D Map solution problem

https://code.sololearn.com/ch1jPmjW468A/?ref=app My solution fails one of the tests but I can't figure out why. Can anyone please suggest what scenario could make it fail? Thank you.

5th Jan 2020, 10:12 AM + 4
I literally just realized that as well. X2 by definition will always be bigger, made the same silly assumption for Y. Simple IF solved it. Thanks!
5th Jan 2020, 10:22 AM + 3
In code 1 case error
2nd Jun 2020, 9:15 AM
SAN 11th Jan 2021, 1:32 PM
SUJAN + 1
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,b,b,b dist = abs(x2 - x1) + abs(y2 - y1) print(dist)
14th Dec 2021, 4:56 PM
Mateo González Bufi 17th Dec 2021, 9:42 AM
Almantas Seikis 0
My solution od this task: import re maps = list(enumerate(re.sub("," , "", input()))) position = [] coordinates = [] for pos, letter in maps: if letter == "P": position.append(pos) for numbers in position: x = numbers // 5 y = numbers % 5 coordinate = [x,y] coordinates.append(coordinate) steps = abs(coordinates - coordinates) + abs(coordinates - coordinates) print(steps) How can I write it shorter?
11th Apr 2022, 4:07 PM
Przemysław Komański 