Log in

View Full Version : Random addition


meenagaurav
Sep 19, 2007, 02:55 AM
I want help to sum the diff. subset
You are given n coins, each of different denomination ( for this take n different
values as input from user).
Let input is v1,v2,v3------,vn.

You have to find how many different amounts you can pay by using these n coins.

asterisk_man
Sep 21, 2007, 01:13 PM
pseudo code (implementation is left as an exercise for the reader):

for 0 < I <= n
foreach combination genCombinations(vList I)
print(sum(combination))

there's probably an easier way to do it since generation of combinations this way will duplicate work but this is the easiest way to describe it.