Repository: TheAlgorithms/Python
Pull request: Add Cramer's rule for solving system of linear equations in two variables
### Describe your change:

Fixes #7122 

* [x] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [] Documentation change?

### Checklist:
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is all my own work -- I have not plagiarized.
* [x] I know that pull requests will not be merged if they fail the automated tests.
* [x] This PR only changes one algorithm file.  To ease review, please open separate PRs for separate algorithms.
* [x] All new Python files are placed inside an existing directory.
* [x] All filenames are in all lowercase characters with no spaces or dashes.
* [x] All functions and variable names follow Python naming conventions.
* [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html).
* [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing.
* [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
* [x] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.


Problem statement:
System of linear equation in 2 variable.
### Feature description

I want to implement a new module inside the matrix ... To solve the System of linear equations in 2 variables using Cramer's Rule. 

### Would you like to work on this feature?

- [X] Yes, I want to work on this feature!

Hints from issue discussion:
Please, assign me this, I want to work on this.
Bro, I want to work on this that's why I CREATED THIS ISSUE 🥲🥲 I m not maintainer ... I m contributor. 
Please leave this, try other issues.
Please assign me this issue.

Commit message: added script for solving system of linear equations in two variables

Patch to review:
diff --git a/matrix/system_of_linear_equation_in_2_variables.py b/matrix/system_of_linear_equation_in_2_variables.py
new file mode 100644
index 000000000000..aac84ce60072
--- /dev/null
+++ b/matrix/system_of_linear_equation_in_2_variables.py
@@ -0,0 +1,84 @@
+def calculate_x_and_y(eq1, eq2):
+    """
+    Solves the system of linear equation in 2 variables.
+    :param: eq1: list of 3 numbers
+    :param: eq2: list of 3 numbers
+    :return: String of result
+    Theory:-
+    https://www.mathsisfun.com/algebra/systems-linear-equations-matrices.html
+    Cramer's rule for 2x2 matrix:-
+    https://www.chilimath.com/lessons/advanced-algebra/cramers-rule-with-two-variables
+    a1x + b1y = = d1
+    a2x + b2y = = d2
+    input format : [a1, b1, d1], [a2, b2, d2]
+    d_matrix = [[a1, b1], [a2, b2]]
+    d is determinant of matrix d_matrix
+    dx_matrix = [[d1, b1], [d2, b2]]
+    dx is determinant of matrix dx_matrix
+    dy_matrix = [[a1, d1], [a2, d2]]
+    dy is determinant of matrix dy_matrix
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 6])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 7])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [11, 22])
+    Traceback (most recent call last):
+        ...
+    ValueError: Please enter a valid equation.
+
+    >>> calculate_x_and_y([11, 2, 30], [1, 0, 4])
+    'Non-Trivial Solution (Consistent system) x = 4.0, y = -7.0'
+
+    >>> calculate_x_and_y([0, 1, 6], [0, 0, 3])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([0, 0, 6], [0, 0, 3])
+    Both a & b of two equations can't be zero.
+
+    >>> calculate_x_and_y([4, 7, 1], [1, 2, 0])
+    'Non-Trivial Solution (Consistent system) x = 2.0, y = -1.0'
+
+    >>> calculate_x_and_y([1, 2, 3], [1, 2, 3])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([2, 3, 0], [5, 1, 0])
+    'Trivial solution. (Consistent system) x = 0 and y = 0'
+
+    >>> calculate_x_and_y([0, 4, 50], [2, 0, 26])
+    'Non-Trivial Solution (Consistent system) x = 13.0, y = 12.5'
+
+    >>> calculate_x_and_y([0, 4, 50], [0, 3, 99])
+    'No solution. (Inconsistent system)'
+    """
+
+    # Checking if the input is valid
+    if len(eq1) != 3 or len(eq2) != 3:
+        raise ValueError("Please enter a valid equation.")
+    elif (eq1[0] == 0 and eq1[1] == 0) and (eq2[0] == 0 and eq2[1] == 0):
+        print("Both a & b of two equations can't be zero.")
+    else:
+        # Extracting the coefficients
+        a1, b1, c1 = eq1
+        a2, b2, c2 = eq2
+
+        # Calculating the determinant of matrix d_matrix, dx_matrix and dy_matrix
+        d = a1 * b2 - a2 * b1
+        dx = c1 * b2 - c2 * b1
+        dy = a1 * c2 - a2 * c1
+
+        # Checking if the system of linear equation has a solution (Using Cramer's rule)
+        if d == 0:
+            if dx == 0 and dy == 0:
+                return "Infinite solutions. (Consistent system)"
+            else:
+                return "No solution. (Inconsistent system)"
+        else:
+            if dx == 0 and dy == 0:
+                return f"Trivial solution. (Consistent system) x = {0} and y = {0}"
+            else:
+                x = dx / d
+                y = dy / d
+                return f"Non-Trivial Solution (Consistent system) x = {x}, y = {y}"


Code review comments:
diff_hunk: @@ -0,0 +1,84 @@
+def calculate_x_and_y(eq1, eq2):
+    """
+    Solves the system of linear equation in 2 variables.
+    :param: eq1: list of 3 numbers
+    :param: eq2: list of 3 numbers
+    :return: String of result
+    Theory:-
+    https://www.mathsisfun.com/algebra/systems-linear-equations-matrices.html
+    Cramer's rule for 2x2 matrix:-
+    https://www.chilimath.com/lessons/advanced-algebra/cramers-rule-with-two-variables
+    a1x + b1y = = d1
+    a2x + b2y = = d2
+    input format : [a1, b1, d1], [a2, b2, d2]
+    d_matrix = [[a1, b1], [a2, b2]]
+    d is determinant of matrix d_matrix
+    dx_matrix = [[d1, b1], [d2, b2]]
+    dx is determinant of matrix dx_matrix
+    dy_matrix = [[a1, d1], [a2, d2]]
+    dy is determinant of matrix dy_matrix
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 6])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 7])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [11, 22])
+    Traceback (most recent call last):
+        ...
+    ValueError: Please enter a valid equation.
+
+    >>> calculate_x_and_y([11, 2, 30], [1, 0, 4])
+    'Non-Trivial Solution (Consistent system) x = 4.0, y = -7.0'
+
+    >>> calculate_x_and_y([0, 1, 6], [0, 0, 3])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([0, 0, 6], [0, 0, 3])
+    Both a & b of two equations can't be zero.
+
+    >>> calculate_x_and_y([4, 7, 1], [1, 2, 0])
+    'Non-Trivial Solution (Consistent system) x = 2.0, y = -1.0'
+
+    >>> calculate_x_and_y([1, 2, 3], [1, 2, 3])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([2, 3, 0], [5, 1, 0])
+    'Trivial solution. (Consistent system) x = 0 and y = 0'
+
+    >>> calculate_x_and_y([0, 4, 50], [2, 0, 26])
+    'Non-Trivial Solution (Consistent system) x = 13.0, y = 12.5'
+
+    >>> calculate_x_and_y([0, 4, 50], [0, 3, 99])
+    'No solution. (Inconsistent system)'
+    """
+
+    # Checking if the input is valid
+    if len(eq1) != 3 or len(eq2) != 3:
+        raise ValueError("Please enter a valid equation.")
+    elif (eq1[0] == 0 and eq1[1] == 0) and (eq2[0] == 0 and eq2[1] == 0):
+        print("Both a & b of two equations can't be zero.")
+    else:
+        # Extracting the coefficients
+        a1, b1, c1 = eq1
+        a2, b2, c2 = eq2
+
+        # Calculating the determinant of matrix d_matrix, dx_matrix and dy_matrix
+        d = a1 * b2 - a2 * b1
+        dx = c1 * b2 - c2 * b1
+        dy = a1 * c2 - a2 * c1
+
+        # Checking if the system of linear equation has a solution (Using Cramer's rule)
+        if d == 0:
+            if dx == 0 and dy == 0:
+                return "Infinite solutions. (Consistent system)"
+            else:
+                return "No solution. (Inconsistent system)"
path: matrix/system_of_linear_equation_in_2_variables.py
text: @user1:
```suggestion
            raise RuntimeError("No solution. (Inconsistent system)")
```

diff_hunk: @@ -0,0 +1,84 @@
+def calculate_x_and_y(eq1, eq2):
+    """
+    Solves the system of linear equation in 2 variables.
+    :param: eq1: list of 3 numbers
+    :param: eq2: list of 3 numbers
+    :return: String of result
+    Theory:-
+    https://www.mathsisfun.com/algebra/systems-linear-equations-matrices.html
+    Cramer's rule for 2x2 matrix:-
+    https://www.chilimath.com/lessons/advanced-algebra/cramers-rule-with-two-variables
+    a1x + b1y = = d1
+    a2x + b2y = = d2
+    input format : [a1, b1, d1], [a2, b2, d2]
+    d_matrix = [[a1, b1], [a2, b2]]
+    d is determinant of matrix d_matrix
+    dx_matrix = [[d1, b1], [d2, b2]]
+    dx is determinant of matrix dx_matrix
+    dy_matrix = [[a1, d1], [a2, d2]]
+    dy is determinant of matrix dy_matrix
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 6])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 7])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [11, 22])
+    Traceback (most recent call last):
+        ...
+    ValueError: Please enter a valid equation.
+
+    >>> calculate_x_and_y([11, 2, 30], [1, 0, 4])
+    'Non-Trivial Solution (Consistent system) x = 4.0, y = -7.0'
+
+    >>> calculate_x_and_y([0, 1, 6], [0, 0, 3])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([0, 0, 6], [0, 0, 3])
+    Both a & b of two equations can't be zero.
+
+    >>> calculate_x_and_y([4, 7, 1], [1, 2, 0])
+    'Non-Trivial Solution (Consistent system) x = 2.0, y = -1.0'
+
+    >>> calculate_x_and_y([1, 2, 3], [1, 2, 3])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([2, 3, 0], [5, 1, 0])
+    'Trivial solution. (Consistent system) x = 0 and y = 0'
+
+    >>> calculate_x_and_y([0, 4, 50], [2, 0, 26])
+    'Non-Trivial Solution (Consistent system) x = 13.0, y = 12.5'
+
+    >>> calculate_x_and_y([0, 4, 50], [0, 3, 99])
+    'No solution. (Inconsistent system)'
+    """
+
+    # Checking if the input is valid
+    if len(eq1) != 3 or len(eq2) != 3:
+        raise ValueError("Please enter a valid equation.")
+    elif (eq1[0] == 0 and eq1[1] == 0) and (eq2[0] == 0 and eq2[1] == 0):
+        print("Both a & b of two equations can't be zero.")
+    else:
+        # Extracting the coefficients
+        a1, b1, c1 = eq1
+        a2, b2, c2 = eq2
+
+        # Calculating the determinant of matrix d_matrix, dx_matrix and dy_matrix
+        d = a1 * b2 - a2 * b1
+        dx = c1 * b2 - c2 * b1
+        dy = a1 * c2 - a2 * c1
+
+        # Checking if the system of linear equation has a solution (Using Cramer's rule)
+        if d == 0:
+            if dx == 0 and dy == 0:
+                return "Infinite solutions. (Consistent system)"
+            else:
+                return "No solution. (Inconsistent system)"
+        else:
+            if dx == 0 and dy == 0:
+                return f"Trivial solution. (Consistent system) x = {0} and y = {0}"
+            else:
+                x = dx / d
+                y = dy / d
+                return f"Non-Trivial Solution (Consistent system) x = {x}, y = {y}"
path: matrix/system_of_linear_equation_in_2_variables.py
text: @user1:
```suggestion
            x = dx / d
            y = dy / d
            raise RuntimeError(f"Non-Trivial Solution (Consistent system) x = {x}, y = {y}")
```

diff_hunk: @@ -0,0 +1,84 @@
+def calculate_x_and_y(eq1, eq2):
path: matrix/system_of_linear_equation_in_2_variables.py
text: @user1:
```suggestion
def calculate_x_and_y(eq1: list[int], eq2: list[int]) -> str:
```

@author:
what should I type in place of str if it will raise only runtime error (according to @user2 's changes) ??

@user2:
> what should I type in place of str if it will raise only runtime error (according to @user2 's changes) ??

Runtime error doesnt count as a return type, it implies a return type of `None`

@user1:
Exceptions that are raised are NOT return values.  The way to think about this is that if the function succeeds (no Exceptions are raised) then the caller should expect to receive a str.

diff_hunk: @@ -0,0 +1,84 @@
+def calculate_x_and_y(eq1, eq2):
+    """
+    Solves the system of linear equation in 2 variables.
+    :param: eq1: list of 3 numbers
+    :param: eq2: list of 3 numbers
+    :return: String of result
+    Theory:-
+    https://www.mathsisfun.com/algebra/systems-linear-equations-matrices.html
+    Cramer's rule for 2x2 matrix:-
+    https://www.chilimath.com/lessons/advanced-algebra/cramers-rule-with-two-variables
+    a1x + b1y = = d1
+    a2x + b2y = = d2
+    input format : [a1, b1, d1], [a2, b2, d2]
+    d_matrix = [[a1, b1], [a2, b2]]
+    d is determinant of matrix d_matrix
+    dx_matrix = [[d1, b1], [d2, b2]]
+    dx is determinant of matrix dx_matrix
+    dy_matrix = [[a1, d1], [a2, d2]]
+    dy is determinant of matrix dy_matrix
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 6])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 7])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [11, 22])
+    Traceback (most recent call last):
+        ...
+    ValueError: Please enter a valid equation.
+
+    >>> calculate_x_and_y([11, 2, 30], [1, 0, 4])
+    'Non-Trivial Solution (Consistent system) x = 4.0, y = -7.0'
+
+    >>> calculate_x_and_y([0, 1, 6], [0, 0, 3])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([0, 0, 6], [0, 0, 3])
+    Both a & b of two equations can't be zero.
+
+    >>> calculate_x_and_y([4, 7, 1], [1, 2, 0])
+    'Non-Trivial Solution (Consistent system) x = 2.0, y = -1.0'
+
+    >>> calculate_x_and_y([1, 2, 3], [1, 2, 3])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([2, 3, 0], [5, 1, 0])
+    'Trivial solution. (Consistent system) x = 0 and y = 0'
+
+    >>> calculate_x_and_y([0, 4, 50], [2, 0, 26])
+    'Non-Trivial Solution (Consistent system) x = 13.0, y = 12.5'
+
+    >>> calculate_x_and_y([0, 4, 50], [0, 3, 99])
+    'No solution. (Inconsistent system)'
+    """
+
+    # Checking if the input is valid
+    if len(eq1) != 3 or len(eq2) != 3:
+        raise ValueError("Please enter a valid equation.")
+    elif (eq1[0] == 0 and eq1[1] == 0) and (eq2[0] == 0 and eq2[1] == 0):
+        print("Both a & b of two equations can't be zero.")
path: matrix/system_of_linear_equation_in_2_variables.py
text: @user1:
```suggestion
    if not len(eq1) == len(eq2) == 3:
        raise ValueError("Please enter a valid equation.")
    elif eq1[0] == eq1[1] == eq2[0] == eq2[1] == 0:
        print("Both a & b of two equations can't be zero.")  # This should raise a ValueError()
```

diff_hunk: @@ -0,0 +1,84 @@
+def calculate_x_and_y(eq1, eq2):
+    """
+    Solves the system of linear equation in 2 variables.
+    :param: eq1: list of 3 numbers
+    :param: eq2: list of 3 numbers
+    :return: String of result
+    Theory:-
+    https://www.mathsisfun.com/algebra/systems-linear-equations-matrices.html
+    Cramer's rule for 2x2 matrix:-
+    https://www.chilimath.com/lessons/advanced-algebra/cramers-rule-with-two-variables
+    a1x + b1y = = d1
+    a2x + b2y = = d2
+    input format : [a1, b1, d1], [a2, b2, d2]
+    d_matrix = [[a1, b1], [a2, b2]]
+    d is determinant of matrix d_matrix
+    dx_matrix = [[d1, b1], [d2, b2]]
+    dx is determinant of matrix dx_matrix
+    dy_matrix = [[a1, d1], [a2, d2]]
+    dy is determinant of matrix dy_matrix
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 6])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 7])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [11, 22])
+    Traceback (most recent call last):
+        ...
+    ValueError: Please enter a valid equation.
+
+    >>> calculate_x_and_y([11, 2, 30], [1, 0, 4])
+    'Non-Trivial Solution (Consistent system) x = 4.0, y = -7.0'
+
+    >>> calculate_x_and_y([0, 1, 6], [0, 0, 3])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([0, 0, 6], [0, 0, 3])
+    Both a & b of two equations can't be zero.
+
+    >>> calculate_x_and_y([4, 7, 1], [1, 2, 0])
+    'Non-Trivial Solution (Consistent system) x = 2.0, y = -1.0'
+
+    >>> calculate_x_and_y([1, 2, 3], [1, 2, 3])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([2, 3, 0], [5, 1, 0])
+    'Trivial solution. (Consistent system) x = 0 and y = 0'
+
+    >>> calculate_x_and_y([0, 4, 50], [2, 0, 26])
+    'Non-Trivial Solution (Consistent system) x = 13.0, y = 12.5'
+
+    >>> calculate_x_and_y([0, 4, 50], [0, 3, 99])
+    'No solution. (Inconsistent system)'
+    """
+
+    # Checking if the input is valid
+    if len(eq1) != 3 or len(eq2) != 3:
+        raise ValueError("Please enter a valid equation.")
+    elif (eq1[0] == 0 and eq1[1] == 0) and (eq2[0] == 0 and eq2[1] == 0):
+        print("Both a & b of two equations can't be zero.")
+    else:
+        # Extracting the coefficients
+        a1, b1, c1 = eq1
+        a2, b2, c2 = eq2
+
+        # Calculating the determinant of matrix d_matrix, dx_matrix and dy_matrix
+        d = a1 * b2 - a2 * b1
+        dx = c1 * b2 - c2 * b1
+        dy = a1 * c2 - a2 * c1
+
+        # Checking if the system of linear equation has a solution (Using Cramer's rule)
+        if d == 0:
+            if dx == 0 and dy == 0:
+                return "Infinite solutions. (Consistent system)"
+            else:
+                return "No solution. (Inconsistent system)"
+        else:
+            if dx == 0 and dy == 0:
+                return f"Trivial solution. (Consistent system) x = {0} and y = {0}"
path: matrix/system_of_linear_equation_in_2_variables.py
text: @user1:
```suggestion
                raise RuntimeError(f"Trivial solution. (Consistent system) x = {0} and y = {0}")
```

diff_hunk: @@ -0,0 +1,84 @@
+def calculate_x_and_y(eq1, eq2):
+    """
+    Solves the system of linear equation in 2 variables.
+    :param: eq1: list of 3 numbers
+    :param: eq2: list of 3 numbers
+    :return: String of result
+    Theory:-
+    https://www.mathsisfun.com/algebra/systems-linear-equations-matrices.html
+    Cramer's rule for 2x2 matrix:-
+    https://www.chilimath.com/lessons/advanced-algebra/cramers-rule-with-two-variables
+    a1x + b1y = = d1
+    a2x + b2y = = d2
+    input format : [a1, b1, d1], [a2, b2, d2]
+    d_matrix = [[a1, b1], [a2, b2]]
+    d is determinant of matrix d_matrix
+    dx_matrix = [[d1, b1], [d2, b2]]
+    dx is determinant of matrix dx_matrix
+    dy_matrix = [[a1, d1], [a2, d2]]
+    dy is determinant of matrix dy_matrix
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 6])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 7])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [11, 22])
+    Traceback (most recent call last):
+        ...
+    ValueError: Please enter a valid equation.
+
+    >>> calculate_x_and_y([11, 2, 30], [1, 0, 4])
+    'Non-Trivial Solution (Consistent system) x = 4.0, y = -7.0'
+
+    >>> calculate_x_and_y([0, 1, 6], [0, 0, 3])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([0, 0, 6], [0, 0, 3])
+    Both a & b of two equations can't be zero.
+
+    >>> calculate_x_and_y([4, 7, 1], [1, 2, 0])
+    'Non-Trivial Solution (Consistent system) x = 2.0, y = -1.0'
+
+    >>> calculate_x_and_y([1, 2, 3], [1, 2, 3])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([2, 3, 0], [5, 1, 0])
+    'Trivial solution. (Consistent system) x = 0 and y = 0'
+
+    >>> calculate_x_and_y([0, 4, 50], [2, 0, 26])
+    'Non-Trivial Solution (Consistent system) x = 13.0, y = 12.5'
+
+    >>> calculate_x_and_y([0, 4, 50], [0, 3, 99])
+    'No solution. (Inconsistent system)'
+    """
+
+    # Checking if the input is valid
+    if len(eq1) != 3 or len(eq2) != 3:
+        raise ValueError("Please enter a valid equation.")
+    elif (eq1[0] == 0 and eq1[1] == 0) and (eq2[0] == 0 and eq2[1] == 0):
+        print("Both a & b of two equations can't be zero.")
+    else:
+        # Extracting the coefficients
+        a1, b1, c1 = eq1
+        a2, b2, c2 = eq2
+
+        # Calculating the determinant of matrix d_matrix, dx_matrix and dy_matrix
+        d = a1 * b2 - a2 * b1
+        dx = c1 * b2 - c2 * b1
+        dy = a1 * c2 - a2 * c1
+
+        # Checking if the system of linear equation has a solution (Using Cramer's rule)
+        if d == 0:
+            if dx == 0 and dy == 0:
+                return "Infinite solutions. (Consistent system)"
+            else:
+                return "No solution. (Inconsistent system)"
+        else:
+            if dx == 0 and dy == 0:
+                return f"Trivial solution. (Consistent system) x = {0} and y = {0}"
+            else:
+                x = dx / d
+                y = dy / d
+                return f"Non-Trivial Solution (Consistent system) x = {x}, y = {y}"
path: matrix/system_of_linear_equation_in_2_variables.py
text: @user1:
```suggestion
            if dx == dy == 0:
                return "Infinite solutions. (Consistent system)"  # This should raise a ValueError()
            else:
                return "No solution. (Inconsistent system)"  # This should raise a ValueError()
        else:
            if dx == dy == 0:
                return "Trivial solution. (Consistent system) x = 0 and y = 0"
            else:
                return f"Non-Trivial Solution (Consistent system) x = {dx / d}, y = {dy / d}"
```

diff_hunk: @@ -0,0 +1,84 @@
+def calculate_x_and_y(eq1, eq2):
+    """
+    Solves the system of linear equation in 2 variables.
+    :param: eq1: list of 3 numbers
+    :param: eq2: list of 3 numbers
+    :return: String of result
+    Theory:-
+    https://www.mathsisfun.com/algebra/systems-linear-equations-matrices.html
+    Cramer's rule for 2x2 matrix:-
+    https://www.chilimath.com/lessons/advanced-algebra/cramers-rule-with-two-variables
+    a1x + b1y = = d1
+    a2x + b2y = = d2
+    input format : [a1, b1, d1], [a2, b2, d2]
+    d_matrix = [[a1, b1], [a2, b2]]
+    d is determinant of matrix d_matrix
+    dx_matrix = [[d1, b1], [d2, b2]]
+    dx is determinant of matrix dx_matrix
+    dy_matrix = [[a1, d1], [a2, d2]]
+    dy is determinant of matrix dy_matrix
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 6])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 7])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [11, 22])
+    Traceback (most recent call last):
+        ...
+    ValueError: Please enter a valid equation.
+
+    >>> calculate_x_and_y([11, 2, 30], [1, 0, 4])
+    'Non-Trivial Solution (Consistent system) x = 4.0, y = -7.0'
+
+    >>> calculate_x_and_y([0, 1, 6], [0, 0, 3])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([0, 0, 6], [0, 0, 3])
+    Both a & b of two equations can't be zero.
+
+    >>> calculate_x_and_y([4, 7, 1], [1, 2, 0])
+    'Non-Trivial Solution (Consistent system) x = 2.0, y = -1.0'
+
+    >>> calculate_x_and_y([1, 2, 3], [1, 2, 3])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([2, 3, 0], [5, 1, 0])
+    'Trivial solution. (Consistent system) x = 0 and y = 0'
+
+    >>> calculate_x_and_y([0, 4, 50], [2, 0, 26])
+    'Non-Trivial Solution (Consistent system) x = 13.0, y = 12.5'
+
+    >>> calculate_x_and_y([0, 4, 50], [0, 3, 99])
+    'No solution. (Inconsistent system)'
+    """
+
+    # Checking if the input is valid
+    if len(eq1) != 3 or len(eq2) != 3:
+        raise ValueError("Please enter a valid equation.")
+    elif (eq1[0] == 0 and eq1[1] == 0) and (eq2[0] == 0 and eq2[1] == 0):
+        print("Both a & b of two equations can't be zero.")
+    else:
+        # Extracting the coefficients
+        a1, b1, c1 = eq1
+        a2, b2, c2 = eq2
+
+        # Calculating the determinant of matrix d_matrix, dx_matrix and dy_matrix
+        d = a1 * b2 - a2 * b1
+        dx = c1 * b2 - c2 * b1
+        dy = a1 * c2 - a2 * c1
+
+        # Checking if the system of linear equation has a solution (Using Cramer's rule)
+        if d == 0:
+            if dx == 0 and dy == 0:
+                return "Infinite solutions. (Consistent system)"
path: matrix/system_of_linear_equation_in_2_variables.py
text: @user1:
```suggestion
                raise RuntimeError("Infinite solutions. (Consistent system)")
```


@author:
done

diff_hunk: @@ -0,0 +1,84 @@
+def calculate_x_and_y(eq1, eq2):
path: matrix/system_of_linear_equation_in_2_variables.py
text: @user1:
Please provide return type hint for the function: `calculate_x_and_y`. **If the function does not return a value, please provide the type hint as:** `def function() -> None:`

Please provide type hint for the parameter: `eq1`

Please provide type hint for the parameter: `eq2`

@author:
ok 

@author:
Done

diff_hunk: @@ -0,0 +1,84 @@
+def calculate_x_and_y(eq1, eq2):
+    """
+    Solves the system of linear equation in 2 variables.
+    :param: eq1: list of 3 numbers
+    :param: eq2: list of 3 numbers
+    :return: String of result
+    Theory:-
+    https://www.mathsisfun.com/algebra/systems-linear-equations-matrices.html
+    Cramer's rule for 2x2 matrix:-
+    https://www.chilimath.com/lessons/advanced-algebra/cramers-rule-with-two-variables
+    a1x + b1y = = d1
+    a2x + b2y = = d2
+    input format : [a1, b1, d1], [a2, b2, d2]
+    d_matrix = [[a1, b1], [a2, b2]]
+    d is determinant of matrix d_matrix
+    dx_matrix = [[d1, b1], [d2, b2]]
+    dx is determinant of matrix dx_matrix
+    dy_matrix = [[a1, d1], [a2, d2]]
+    dy is determinant of matrix dy_matrix
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 6])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [2, 4, 7])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([1, 2, 3], [11, 22])
+    Traceback (most recent call last):
+        ...
+    ValueError: Please enter a valid equation.
+
+    >>> calculate_x_and_y([11, 2, 30], [1, 0, 4])
+    'Non-Trivial Solution (Consistent system) x = 4.0, y = -7.0'
+
+    >>> calculate_x_and_y([0, 1, 6], [0, 0, 3])
+    'No solution. (Inconsistent system)'
+
+    >>> calculate_x_and_y([0, 0, 6], [0, 0, 3])
+    Both a & b of two equations can't be zero.
+
+    >>> calculate_x_and_y([4, 7, 1], [1, 2, 0])
+    'Non-Trivial Solution (Consistent system) x = 2.0, y = -1.0'
+
+    >>> calculate_x_and_y([1, 2, 3], [1, 2, 3])
+    'Infinite solutions. (Consistent system)'
+
+    >>> calculate_x_and_y([2, 3, 0], [5, 1, 0])
+    'Trivial solution. (Consistent system) x = 0 and y = 0'
+
+    >>> calculate_x_and_y([0, 4, 50], [2, 0, 26])
+    'Non-Trivial Solution (Consistent system) x = 13.0, y = 12.5'
+
+    >>> calculate_x_and_y([0, 4, 50], [0, 3, 99])
+    'No solution. (Inconsistent system)'
+    """
+
+    # Checking if the input is valid
+    if len(eq1) != 3 or len(eq2) != 3:
+        raise ValueError("Please enter a valid equation.")
+    elif (eq1[0] == 0 and eq1[1] == 0) and (eq2[0] == 0 and eq2[1] == 0):
+        print("Both a & b of two equations can't be zero.")
path: matrix/system_of_linear_equation_in_2_variables.py
text: @user1:
```suggestion
        raise ValueError("Both a & b of two equations can't be zero.")
```


@author:
okie, done