Dynamic programming

This is just for debugging.