Python solution for Rod-cutting problem with both a naive and optimized solution using memoization to drastically improve computation performance