Implement caching for matrix inversion - week 3 programming assignment