Completed assignment 2, matrix caching