dynamic programming SoDoge