### PROBLEM ### """ We are given a rod of length n and we are given the array of prices, also of length n. This array contains the price for selling a rod at a certain length. For example, prices[5] shows the price we can sell a rod of length 5. Generalising, prices[x] shows the price a rod of length x can be sold. We are tasked to find the optimal solution to sell the given rod. """ ### SOLUTION ### """ Profit(n) = max(1 m): m = yesCut[i] solutions[n] = m return m ### EXAMPLE ### length = 5 #The first price, 0, is for when we have no rod. prices = [0, 1, 3, 7, 9, 11, 13, 17, 21, 21, 30] solutions = [-1 for x in range(length+1)] print(CutRod(length))