function y = myDet(A)

    [r, ~] = size(A);
    if r == 1
        y = A;
    elseif r == 2
        y = A(1, 1) * A(2, 2) - A(1, 2) * A(2, 1);
    else
        y = 0;
        for i = 1 : r
            B = A(2 : r, [1 : i - 1, i + 1 : r]);
            cofactor = (-1) ^ (i + 1) * myDet(B);
            y = y + A(1, i) * cofactor;
        end
    end
end