There is a pretty complex problem that I know the answer to, but I cannot develop any intuition that could help me implement the algorithm capable of printing the solution in finite amount of time.
Problem
In the principality of Potluck, the currency is the Fluke, worth 100 Jammies. The Bank of Potluck has just issued the new One Fluke note but now wants a coin system for the Jammies. The plan is that you should be able to make ANY amount between 1 and 100 Jammies by using just one or two coins. (The two coins can be the same or different.) What is the smallest number of different coins they need for their new system – and what are they?
Here are some sample solutions for a smaller range of Jammies:
Range | Coins Set |
1 to 1 => [1]
1 to 2 => [1]
1 to 3 => [1, 3]
or [1, 2]
1 to 4 => [1, 2]
or [1, 3]
1 to 5 => [1, 3, 5]
or [1, 2, 5]
or [1, 2, 4]
or [1, 3, 4]
Explanation: For all values between 1 and 5, you can use one of [[1, 3, 5],[1, 2, 5],[1, 2, 4],[1, 3, 4]]
coin values to construct any value between 1 and 5 using at most two coins out of the chosen set of coin values.
Questions and concerns
I have tried simple Memo, tries, DP, but none of them seem to work for 1-100 Jammies. The best I got was that the program was jamming on 1-68 Jammies ([1,3,5,7,8,17,18,27,28,30,32,34,35]
13 coins).
Can anyone help me approach the problem in a computable way?