Solution for the CacheMatrix Assignment