Dynamic programming solution of a not so interesting problem