adding logic to get the optimum solution for rod cut problem