Exercise Solution

This solution can handle square and non square matrices.