Rewrite 2-3_limited-partial-sum as dynamic programming.