Skip to content

Commit 03a0843

Browse files
Merge pull request #2155 from CodingTestStudy2/최원준
[최원준] 2026/10/09
2 parents 65bef85 + a17f3cc commit 03a0843

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Solution:
2+
def validSquare(self, p1: list[int], p2: list[int], p3: list[int], p4: list[int]) -> bool:
3+
4+
def get_distance(p1, p2):
5+
x1, y1 = p1
6+
x2, y2 = p2
7+
return (x1-x2) ** 2 + (y1-y2) ** 2
8+
9+
points=[p1,p2,p3,p4]
10+
distances = []
11+
12+
for i in range(4):
13+
for j in range(i+1, 4):
14+
distances.append(get_distance(points[i], points[j]))
15+
16+
distances.sort()
17+
18+
return (
19+
distances[0] > 0
20+
and distances[0] == distances[1] == distances[2] == distances[3]
21+
and distances[4] == distances[5]
22+
and distances[4] == 2 * distances[0]
23+
)

0 commit comments

Comments
 (0)