Quote:
I need to find the maximum number of points lieing on a single line.(IF possible dont use Python, c#recmommended)
First problem with your code : What tells you that the first 2 points in input are part of the strait line ?
As far as I can see, your code do not list the points on the line, and thus do not sort them.
Since the input can contain points with more than 1 line, there is only 1 algorithm :
- Supposing the input list do not contain the same point 2 time.
1- Choose a first point
2- Choose a second point
3- Check remaining point for being on same line
4- As you find a new point on same line, add it to a list of points
5- at the end of check, if new list is longer than previous list, remember for result
6- Take another second point and go back to 3
7- Take another first point and go back to 2
8- Sort longest list and return as result