A Simple Implementation of Dynamic Programming