cachematrix: implement my solution to the assignment