Missing Data from Assignment 11 Q1

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.)

image