```
def maxPoints(self, points):
answer = 0
for p in points:
pctr = 0
ctr = collections.Counter()
for q in points:
x, y = q.x - p.x, q.y - p.y
pctr += x == y == 0
ctr[float(y)/x if x else 'inf'] += 1
ctr['inf'] -= pctr
answer = max(answer, pctr + max(ctr.values()))
return answer
```

For each point p...

- Count how often p itself appears.
- Count how often each slope through p appears (use 'inf' for vertical lines).
- The p-counter plus the largest slope-counter tell the largest number of points on a line through p.

Maximize the latter over all points p.

Implementation detail: I count every p towards `ctr['inf']`

and subtract them afterwards because that's slightly simpler/shorter and because this way, `ctr`

can't be empty (which would give me trouble when asking `max(ctr.values())`

).