Skip to content

Commit cce1c35

Browse files
authored
Update erect-the-fence.py
1 parent f273072 commit cce1c35

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Python/erect-the-fence.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ def outerTrees(self, points):
1212
:rtype: List[List[int]]
1313
"""
1414
def ccw(A, B, C):
15-
return (B[0]-A[0])*(C[1]-A[1]) - \
16-
(B[1]-A[1])*(C[0]-A[0])
15+
return (B[0]-A[0])*(C[1]-A[1]) - (B[1]-A[1])*(C[0]-A[0])
1716

1817
hull = []
19-
points.sort(key=lambda p: (p[0], p[1]))
20-
for i in itertools.chain(xrange(len(points)), \
21-
reversed(xrange(len(points)))):
18+
points.sort()
19+
for i in itertools.chain(xrange(len(points)), reversed(xrange(len(points)))):
2220
while len(hull) >= 2 and \
2321
ccw(hull[-2], hull[-1], points[i]) < 0:
2422
hull.pop()

0 commit comments

Comments
 (0)