Added solution to calculate inverse of a matrix and cache it, in case
quried for it again.