@@ -0,0 +1,1816 @@
+package org.xander.behavioral.lazyevaluation;%0A%0Aimport java.util.Arrays;%0Aimport java.util.List;%0Aimport java.util.function.BiFunction;%0Aimport java.util.function.Function;%0A%0Aimport static org.xander.behavioral.lazyevaluation.Memoizer.callMemoized;%0A%0Apublic class RodCutterBasic %7B%0A%0A    public RodCutterBasic(final List%3CInteger%3E pricesForLength) %7B%0A        prices = pricesForLength;%0A    %7D%0A%0A    final List%3CInteger%3E prices;%0A%0A    public int maxProfit(final int length) %7B%0A        int profit = (length %3C= prices.size()) ? prices.get(length - 1) : 0;%0A        for (int i = 1; i %3C length; i++) %7B%0A            int priceWhenCut = maxProfit(i) + maxProfit(length - i);%0A            if (profit %3C priceWhenCut) profit = priceWhenCut;%0A        %7D%0A        return profit;%0A    %7D%0A%0A    public int maxProfitMemoized(final int rodLength) %7B%0A        BiFunction%3CFunction%3CInteger, Integer%3E, Integer, Integer%3E compute =%0A                (func, length) -%3E %7B%0A                    int profit = (length %3C= prices.size()) ? prices.get(length - 1) : 0;%0A                    for (int i = 1; i %3C length; i++) %7B%0A                        int priceWhenCut = func.apply(i) + func.apply(length - i);%0A                        if (profit %3C priceWhenCut) profit = priceWhenCut;%0A                    %7D%0A                    return profit;%0A                %7D;%0A        return callMemoized(compute, rodLength);%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        final List%3CInteger%3E priceValues = Arrays.asList(2, 1, 1, 2, 2, 2, 1, 8, 9, 15);%0A        RodCutterBasic rodCutterBasic = new RodCutterBasic(priceValues);%0A%0A//        System.out.println(rodCutterBasic.maxProfit(5));%0A//        System.out.println(rodCutterBasic.maxProfit(22));%0A        System.out.println(rodCutterBasic.maxProfitMemoized(5));%0A        System.out.println(rodCutterBasic.maxProfitMemoized(22));%0A    %7D%0A%7D%0A

Create RodCutterBasic.java