Bug: The order of the arguments in the starting function definition is x1, x2, y1, y2, whereas the the order in the test cases is x1, y1, x2, y2.
Technically, this problem is actually requesting the number of unique intersections minus one. For instance in the first case of the test suite, the line crosses the point (5,3) which is shared by four squares, but we count only two, which is the expected behaviour when crossing an edge, but not a vertex: https://imgur.com/a/wCQ6SNG
Remove all the words that end with "ain"
Maximum running product for a string of numbers
Back to basics 8 - Matrix Diagonals
Getting logical indexes
Sum the entries of each column of a matrix which satisfy a logical condition.
Speed of light:Experiment
Number of divisors of a given number
Which way to go?
Recursive Standard Deviation
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office