Change in Python: Approach

Not being an expert in any programming language, I’m making my way through the Python Syllabus. I’m trying to solve the exercise “Change” with what I’ve learned so far but wasn’t able to get past the tests.

Searching online I found a few examples using dynamic programming and peeking into the Community Solutions it turns out that most use combinations_with_replacement from itertools or dynamic programming.

I’m wondering how you approach exercises that you can’t solve with what you know and whether it might be useful to hint using a certain module or technique if the exercise cannot be solved with what has been in the syllabus thus far.

Or, in the case there is a way to solve this exercise without either of the aforementioned, please share.

Sometimes I’ll search for a language-agnostic algorithm for solving the exercise. Wikipedia is ofter a good source for this. You’ll often find some pseudocode that shows how to compute the algorithm. Then I’ll work at translating the pseudocode to the language.

For the Change exercise, I found this paper helpful:

1 Like