function splinesList = findPolicy(budget,funcList,numPoints)
% NOTE: The first element in the spline list is actually EMPTY
% Initialize by setting up a simple grid
budgetGrid = linspace(0,budget,numPoints);
% prepare matrix of function values for each time step
numSteps = length(funcList);
valFunMatrix = zeros(numPoints,numSteps);
% splines will be contained in a cell array
splinesList = cell(numSteps,1);
% start from the last step (increasing contribution functions)
valFunMatrix(:,numSteps) = feval(funcList{numSteps}, budgetGrid);
splinesList{numSteps} = spline(budgetGrid, valFunMatrix(:,numSteps));
% now step backward in time
for t = numSteps-1:-1:2
    % build an objective function by adding the immediate contribution 
    % and the value function at the next stage
    for k = 1:numPoints
        b = budgetGrid(k); % budget for this problem
        objFun = @(x) -(feval(funcList{t},x) + ppval(splinesList{t+1},b-x));
        [~,outVal] = fminbnd(objFun, 0, b);
        valFunMatrix(k,t) = -outVal;
    end % for k
    splinesList{t} = spline(budgetGrid, valFunMatrix(:,t));
end % for t
