Completed assignment

Wrote code for both functions and also included check for invertible
matrix (just as extra check even though we didn’t need to for the
assignment).