Update Python Problem 31

Changed Problem 31 to use a more clever algorithm (where we use the fact
that each change problem is a combination of smaller change problems)
instead of pure brute force.