set / line intersection solution

Posted by Xavier on Stack Overflow See other posts from Stack Overflow or by Xavier
Published on 2010-05-30T16:54:15Z Indexed on 2010/05/30 17:02 UTC
Read the original article Hit count: 285

Filed under:
|
|
|

I have two lists in python and I want to know if they intersect at the same index. Is there a mathematical way of solving this?

For example if I have [9,8,7,6,5] and [3,4,5,6,7] I'd like a simple and efficient formula/algorithm that finds that at index 3 they intersect. I know I could do a search just wondering if there is a better way.

I know there is a formula to solve two lines in y = mx + b form by subtracting them from each other but my "line" isn't truly a line because its limited to the items in the list and it may have curves.

Any help is appreciated.

© Stack Overflow or respective owner

Related posts about python

Related posts about list