Linear functions intersection
Description:
This kata would about function intersections
Function – dependence of one variable on another.
This dependence can be expressed in the coordinate system in the form of a graph, and the graphs of two different linear functions can intersect at no more then one point.
Linear functions are functions of the form: y = mx + b.
Two functions, y1 and y2, intersect one another when, for a specific x, y1(x) = y2(x).
Your task in this kata is to determine whether if two functions intersect with another in a given interval (exclusive). The functions also may not intersect with one another.
For example, given y1 = x - 3, y2 = -x + 3, and the interval (-2,6):
y1 and y2 intersect at the point (3,0) and this intersection lies in the interval (-2 < 3 < 6) so return True
in any other case return False
.
Graphically (shown for illustration purposes only):
5 \ ↑ y :
4 : \ | : /
3 : ⍀ /
2 : | \ / :
1 : | \ / :
0 ——————————:———+—————*—————:——→
-1 : | / \ : x
-2 : | / \ :
-3 : ⌿ \
-4 : / | : \ y=-x+
-7-6-5-4-3-2-1 0 1 2 3 4 5 6 7
'/' - graph of y=x-3, '\' - graph of y=-x+3
'*' - intersection point,
':' - interval boundaries (-2<x<6)
- Intervals are always valid.
- Generation of random tests also allows the absence of some terms of the equation, defining the function, what can make it constant function too.
Enjoy /ᐠ。.。ᐟ\
Similar Kata:
Stats:
Created | Mar 3, 2023 |
Published | Mar 4, 2023 |
Warriors Trained | 50 |
Total Skips | 2 |
Total Code Submissions | 163 |
Total Times Completed | 23 |
Python Completions | 23 |
Total Stars | 1 |
% of votes with a positive feedback rating | 77% of 13 |
Total "Very Satisfied" Votes | 7 |
Total "Somewhat Satisfied" Votes | 6 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 15 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |