dynamic_programming and ps7