memoization optimization - the same rules-vector is not safed again and again by memoization
added matrix-chain-multiplication optimization