Changed from dict-based lookups to array-based lookups for subproblems - faster.
Python version changed to array-based