Assignment 2 solution: "cache matrix"