Interview Query

Intersecting Lines

Have you seen this question before?

Say you are given a list of tuples where the first element is the slope of a line and the second element is the y-intercept of a line.

Write a function find_intersecting to find which lines, if any, intersect with any of the others in the given x_range.



tuple_list = [(2, 3), (-3, 5), (4, 6), (5, 7)]
x_range = (0, 1)


def find_intersecting(tuple_list, x_range) ->  [(2,3), (-3,5)]
Next question: Index Fund Return
Python 3.9.6
Loading editor
Use Shift + Enter to run code