Project Euler 165 - Intersections

Official link: https://projecteuler.net/problem=165

Thought Process

From problem 630 I found a way to generate a line given 2 points, then I created a new function intersect which finds out if 2 lines intersect (A simple google search can find a few articles on how to do this (1), (2), and many more)and if they do whether it is a True intersection or not.

The rest of the problem is easy, just loop through all lines and add all True intersection points to set to remove duplicates and return the length of the set.

Interactive Code

Enter a number (yourinput)

Code will output the distinct number of true intersection points found among the first yourinput line segments