Consider a money system consisting ofĀ n coins. Each coin has a positive integer value. You have two tasks to tackle:
ššš¬š¤ š.
Calculate theĀ number of distinct ways you can produce a money sumĀ x using the available coins.
For example, if the coins areĀ {2, 3, 5} and the desired sum isĀ 9, there areĀ 3Ā ways:
2+2+5
3+3+3
2+2+2+3
Note that the order doesĀ notĀ matter; i.e, 2 + 2 + 5 and 2 + 5 + 2 do not count as two different ways.
ššš¬š¤ š.
Calculate theĀ number of distinct ordered ways you can produce a money sumĀ x using the available coins.
For example, if the coins areĀ {2,3,5} and the desired sum isĀ 9, there areĀ 8Ā ways:
2+2+5
2+5+2
5+2+2
3+3+3
2+2+2+3
2+2+3+2
2+3+2+2
3+2+2+2
You asked your friend to solve both tasks for you, which she did - yay!
But, she gave you the answers without telling you which code solves what problem. Here are the solutions worked out by your friend (see next page). Can you match the solutions to the questions?
(Hint: try simulating the solutions given for the examples above to be sure about your answer.)
Ā

Ā