solution for programming assignment (inverse cache matrix)