Skip to content

Commit c15fa9e

Browse files
authored
Create e1232.py
1 parent bcb5364 commit c15fa9e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

my-submissions/e1232.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution:
2+
def checkStraightLine(self, coordinates: List[List[int]]) -> bool:
3+
x, y = coordinates[0]
4+
x2, y2 = coordinates[1]
5+
if (x == x2 or y == y2) and (x != x2 or y != y2) :
6+
if x == x2 :
7+
return all(a == x2 for a, b in coordinates[2:])
8+
else :
9+
return all(b == y2 for a, b in coordinates[2:])
10+
11+
delta = (y2 - y) / (x2 - x)
12+
13+
try :
14+
return not any((delta != (y2 - y) / (x2 - x)) for x2, y2 in coordinates[2:])
15+
except ZeroDivisionError as zde :
16+
return False

0 commit comments

Comments
 (0)