completed cachematrix.R file with solution