Added check for invertible matrix.

Although the instructions said that matrices should be assumed to be
invertible, I added a check of the determinant anyhow, figuring the
extra calculation was better than the cryptic error message from
solve() for non-invertible matrices.