function [L, U] = solution_hw5_p1(A)
%solution_hw5_p1 Computes the LU decomposition using the algorithm from
%class
%   A - The matrix to compute the LU decomposition of
%   L - Lower triangular matrix
%   U - Upper triangular matrix

    [m, n] = size(A);

    L = eye(m,min(m,n));
    U = A;
    
    for i=1:min(m-1, n)
        for j=i+1:m  
            L(j,i) = U(j,i)/U(i,i);
            U(j,i) = 0;
            for k=i+1:n
                U(j,k) = U(j,k) - L(j,i)*U(i,k);
            end
        end
    end
    
    if m>n 
        U = U(1:n, 1:n);
    end
    
end

