from functools import lru_cache def maximum_value(maximum_weight, items): for w in maximum_weight: if maximum_weight < w: continue @lru_cache def helper(i,w): if i == len(items) or i == 0: