If the order matters, the last example could be very large.
In really life order doesn't matter.
I think we could considered that the order doesn't matter for the last example.
- What this task is asking for is a duplicate of Combinations, only different in that it is asking for a count of combinations that have some property rather than an enumeration of combinations. In Raku the task would literally be:
say +[1, 2, 3, 4, 5].combinations.grep: *.sum == 6
- Order matters; Do you mean 1 + 5 is not the same as 5 + 1? Or do you mean that each coin of the same denomination should be treated separately? (This 1 unit coin is different from that 1 unit coin.) If that is the case there needs to be something that makes them unique.
- 'Count the coins' is a poor name for the task anyway, especially if you are going to have a restriction that order matters. By definition order doesn't matter when making change. It isn't counting coins, it's counting sums.
Stated another way; say, for instance, you were assembling power packs from different canisters of highly reactive fuel. Once you opened a canister, you must use all of it and the power pack has a tightly defined capacity requirement. Your power pack needs to have a capacity of 6 power units and you have fuel canisters with [1, 2, 3, 4, 5] units of fuel. How many ways can you resupply the power pack? Now. How is that problem substantially different from the one you stated? And what does it have to do with counting coins? See why 'counting coins' is a bad name?
Although written in English they look very different, logically this and Subset_sum_problem are the same task. For an algorithm you could try https://academyera.com/sum-of-subsets-problem#:~:text=sum%20of%20subsets%20problem%20is%20nothing%20but%20Suppose,set%20whose%20sum%20adds%20to%20a%20number%20K.
- I checked, they are different. They are different in many ways. At least you may have duplicated elements in the list of coins. --Blek (talk) 16:39, 6 January 2021 (UTC)
- 'archbishop' and 'balm' could both have value 5. Ordering here just means find all permutations of a solution. We have a task for finding all permutations of a set.--Nigel Galloway (talk) 17:07, 6 January 2021 (UTC)
- Here I am looking for an number as ouput and the problem you are talking about wants a set. Let say it is minor difference. The order matters here while it doesn't in the problem you are talking about. Let say also it is a minor difference. The target sum is always zero in the problem you are talking when it may change here. Let say also it is minor difference. Want zero as sum may cause algorithms to use the idea to split set in 2 sets (negative and positive numbers) not easily transferable in this case. Let say it is a minor difference. I won't say many minor differences give a minor difference. --Blek (talk) 17:27, 6 January 2021 (UTC)
- It is also very similar to Permutations_with_some_identical_elements with one extra condition. --Pete Lomax (talk) 22:32, 6 January 2021 (UTC)