Pātuhitia tēnei: The art and theory of dynamic programming