Coursera asses: Calculate the inverse matrix using a cache if it has been calculated before