Challenge: Linear System Solver
Design a Python algorithm to solve a system of linear equations.
We'll cover the following
Statement
Given a system of two linear equations with two unknowns, and , determine if there’s a potential solution. In the case of multiple solutions, return the string “There are infinitely many solutions” in the output. In the case of no solution, return the string “Intersection does not exist” in the output.
Example
Consider an example linear system:
The solution to the system is
Sample inputs and outputs
The following table describes the desired outputs, given the corresponding inputs to the system above, and a few other examples.
Input | Output |
---|---|
, | 25.500 , -10.500 |
, | There are infinitely many solutions |
, | Intersection does not exist |
Note: The output is a string in all cases.
Try it yourself
The signature of the function is given below. It accepts two arrays containing the scalars of the system of linear equations.
Get hands-on with 1200+ tech skills courses.