Ditto coding assignment
Assumptions:
- Input file 'test_example.csv' is present in the same path as the code file 'points.py'.
- Input file is not empty.
- Input file has a line with atleast 2 float values seperated with a comma('). All values above 2 are ignored.
- Program will exit with error code 1 if input file is not readable.
- Program will exit with error code 1 if output cannot be written to a file.
Extra test cases:
- Test case with either X or Y coordinate is missing.
- Test case where X or Y are not float values.
- Empty input file.
- Input file with only 2 lines(not enough data to run the solution).
- Input file with more that 2 values in each line(extra inputs should be ignored).
- Test case where none of the data is on the same lines.
- Test cases where the linear points are either vertically or horizontaly located.
Time complexity:
The time complexity for the solution provided is O(n^2), since we are running two for loops to get the collinear points.
Cases where code can fail:
What if the X coordinates of two points P1 and P2 are such that X2 - X1 is Zero(0). In this case slope of the line joining P1 and P2, will be infinity, resulting in unexpected results. Will need to add a proper fix for this issue.