Talk:Count the coins/0-1: Difference between revisions

From Rosetta Code
Content added Content deleted
(further comment)
m (→‎Several problems: further exposition)
Line 15: Line 15:
# 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.
# 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.
# '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 the the one ''you'' stated? And what does it have to do with counting coins? See why 'counting coins' is a bad name?


--[[User:Thundergnat|Thundergnat]] ([[User talk:Thundergnat|talk]]) 11:13, 6 January 2021 (UTC)
--[[User:Thundergnat|Thundergnat]] ([[User talk:Thundergnat|talk]]) 11:13, 6 January 2021 (UTC)

Revision as of 12:37, 6 January 2021

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.

But seeing both cases when order matters and not would be great. --Blek (talk) 07:02, 6 January 2021 (UTC)

Algorithm

Can you show an algorithm? --Paddy3118 (talk) 07:09, 6 January 2021 (UTC)

Several problems

  1. 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
  2. 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.
  3. '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 the the one you stated? And what does it have to do with counting coins? See why 'counting coins' is a bad name?

--Thundergnat (talk) 11:13, 6 January 2021 (UTC)