dots[i] = [x, y] gives the coordinates of the i-th dot. All dots are distinct.
You need to draw straight lines (infinite in both directions) so that every dot lies on at least one of them. Return the smallest number of lines that does the job.dots=[[0, 0], [1, 1], [2, 2], [0, 2], [2, 0]] → 2
One line goes through [0, 0], [1, 1], [2, 2] and another through [0, 2] and [2, 0]. The five dots are not all on one line, so fewer than two is impossible.
dots=[[3, -1]] → 1
A single dot needs just one line.
dots=[[0, 0], [1, 2], [2, 4], [3, 6]] → 1
dots[i] holds two numbersdots=[[0, 0], [1, 1], [2, 2], [0, 2], [2, 0]]
2
Run checks the first 3 tests in your browser. Submit checks all 97 tests on the server, hidden ones included.