Dynamic Programming Algorithm Examples Python