solution to homework assignment

Solution to the homework assignment. Function creates a matrix object
that caches its own inverse.