Dynamic Programming Python Example