<p>Given an array of <code>points</code> where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> represents a point on the <strong>X-Y</strong> plane, return <em>the maximum number of points that lie on the same straight line</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/25/plane1.jpg" style="width: 300px; height: 294px;" />
<pre>
<strong>Input:</strong> points = [[1,1],[2,2],[3,3]]
<strong>Output:</strong> 3
</pre>

<p><strong class="example">Example 2:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/25/plane2.jpg" style="width: 300px; height: 294px;" />
<pre>
<strong>Input:</strong> points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]
<strong>Output:</strong> 4
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= points.length &lt;= 300</code></li>
	<li><code>points[i].length == 2</code></li>
	<li><code>-10<sup>4</sup> &lt;= x<sub>i</sub>, y<sub>i</sub> &lt;= 10<sup>4</sup></code></li>
	<li>All the <code>points</code> are <strong>unique</strong>.</li>
</ul>

class Solution:
    def maxPoints(self, points: list[list[int]]) -> int:
        if len(points) < 2:
            return len(points) 
        line_set = set()
        count = {}
        def evc_algo (a, b): #assume that both positive
            a_ = a
            b_ = b
            while (a_ != 0 and b_ != 0):
                if (a_ >= b_): a_ = a_ % b_
                else: b_ = b_ % a_
            if a_ == 0:
                return b_
            else: return a_
        def func(x0, x1, y0, y1):
            if (x0 == x1):
                t = (None, x0)
                if t not in line_set:
                    line_set.add(t)
            else:
                if y0 - y1 >= 0: a = y0 - y1
                else: a = - (y0 - y1)
                if x0 - x1 >= 0: b = x0 - x1
                else: b = - (x0 - x1)
                nod = evc_algo(a, b)
                if y1 * (x0 - x1) - x1 * (y0 - y1) >= 0: c = y1 * (x0 - x1) - x1 * (y0 - y1)
                else: c = - (y1* (x0 - x1) - x1 * (y0 - y1))
                nod1 = evc_algo(b, c)
                #####
                t = []
                if (y0 - y1 >= 0 and x0 -x1 >=0) or (y0 - y1 < 0 and x0 - x1 < 0):
                    t.append((a//nod, b//nod))
                else:
                    t.append((-a//nod,b//nod))
                if ((y1* (x0-x1) - x1 * (y0-y1)) >= 0 and x0 -x1 >=0) or ((y1 * (x0-x1) - x1 * (y0-y1)) < 0 and x0 - x1 < 0):
                    t.append((c//nod1, b//nod1))
                else:
                    t.append((-c//nod1, b//nod1))
                t = tuple(t)
                if t not in line_set:
                    line_set.add(t)
        set_point = set()
        for p in points:
            t = tuple(p)
            if t not in set_point:
                set_point.add(t)
        set_point = list(set_point)
        for i in range (len(set_point) - 1):
            for j in range (i + 1, len(set_point)):
                func(set_point[i][0], set_point[j][0], set_point[i][1], set_point[j][1])
        line_set = list(line_set)
        # print(line_set)
        for line in line_set:
            count[line] = 0
            for p in set_point:
                if line == ((70, 23), (9, 1)):
                    print(p[1], (line[0][0] / line[0][1]) * p[0] + line[1][0]/line[1][1])
                if line[0] == None and line[1] == p[0]:
                    count[line] += 1
                elif (line[0] != None and p[1] == (line[0][0] * p[0] * line[1][1] + line[1][0] * line[0][1])/(line[0][1] * line[1][1])):
                    count[line] += 1
        return max(count.values())
31791