https www chilimath comlessonsadvancedalgebracramersrulewithtwovariables https en wikipedia orgwikicramer27srule solves the system of linear equation in 2 variables param equation1 list of 3 numbers param equation2 list of 3 numbers return string of result input format a1 b1 d1 a2 b2 d2 determinant a1 b1 a2 b2 determinantx d1 b1 d2 b2 determinanty a1 d1 a2 d2 cramersrule2x22 3 0 5 1 0 0 0 0 0 cramersrule2x20 4 50 2 0 26 13 0 12 5 cramersrule2x211 2 30 1 0 4 4 0 7 0 cramersrule2x24 7 1 1 2 0 2 0 1 0 cramersrule2x21 2 3 2 4 6 traceback most recent call last valueerror infinite solutions consistent system cramersrule2x21 2 3 2 4 7 traceback most recent call last valueerror no solution inconsistent system cramersrule2x21 2 3 11 22 traceback most recent call last valueerror please enter a valid equation cramersrule2x20 1 6 0 0 3 traceback most recent call last valueerror no solution inconsistent system cramersrule2x20 0 6 0 0 3 traceback most recent call last valueerror both a b of two equations can t be zero cramersrule2x21 2 3 1 2 3 traceback most recent call last valueerror infinite solutions consistent system cramersrule2x20 4 50 0 3 99 traceback most recent call last valueerror no solution inconsistent system check if the input is valid extract the coefficients calculate the determinants of the matrices check if the system of linear equations has a solution using cramer s rule trivial solution inconsistent system nontrivial solution consistent system https www chilimath com lessons advanced algebra cramers rule with two variables https en wikipedia org wiki cramer 27s_rule solves the system of linear equation in 2 variables param equation1 list of 3 numbers param equation2 list of 3 numbers return string of result input format a1 b1 d1 a2 b2 d2 determinant a1 b1 a2 b2 determinant_x d1 b1 d2 b2 determinant_y a1 d1 a2 d2 cramers_rule_2x2 2 3 0 5 1 0 0 0 0 0 cramers_rule_2x2 0 4 50 2 0 26 13 0 12 5 cramers_rule_2x2 11 2 30 1 0 4 4 0 7 0 cramers_rule_2x2 4 7 1 1 2 0 2 0 1 0 cramers_rule_2x2 1 2 3 2 4 6 traceback most recent call last valueerror infinite solutions consistent system cramers_rule_2x2 1 2 3 2 4 7 traceback most recent call last valueerror no solution inconsistent system cramers_rule_2x2 1 2 3 11 22 traceback most recent call last valueerror please enter a valid equation cramers_rule_2x2 0 1 6 0 0 3 traceback most recent call last valueerror no solution inconsistent system cramers_rule_2x2 0 0 6 0 0 3 traceback most recent call last valueerror both a b of two equations can t be zero cramers_rule_2x2 1 2 3 1 2 3 traceback most recent call last valueerror infinite solutions consistent system cramers_rule_2x2 0 4 50 0 3 99 traceback most recent call last valueerror no solution inconsistent system check if the input is valid extract the coefficients calculate the determinants of the matrices check if the system of linear equations has a solution using cramer s rule trivial solution inconsistent system non trivial solution consistent system
def cramers_rule_2x2(equation1: list[int], equation2: list[int]) -> tuple[float, float]:
    

    
    if not len(equation1) == len(equation2) == 3:
        raise ValueError("Please enter a valid equation.")
    if equation1[0] == equation1[1] == equation2[0] == equation2[1] == 0:
        raise ValueError("Both a & b of two equations can't be zero.")

    
    a1, b1, c1 = equation1
    a2, b2, c2 = equation2

    
    determinant = a1 * b2 - a2 * b1
    determinant_x = c1 * b2 - c2 * b1
    determinant_y = a1 * c2 - a2 * c1

    
    if determinant == 0:
        if determinant_x == determinant_y == 0:
            raise ValueError("Infinite solutions. (Consistent system)")
        else:
            raise ValueError("No solution. (Inconsistent system)")
    else:
        if determinant_x == determinant_y == 0:
            
            return (0.0, 0.0)
        else:
            x = determinant_x / determinant
            y = determinant_y / determinant
            
            return (x, y)