Question: money bags procedure

bags.mw

$15 is spread among four different bags. How  can you can make any whole number of dollars from $1 to $15 by selecting some of these bags of money, without taking any money out of the bags.
 
How is the money distributed ?

One bag must have $1 in it.
To be able to make $2, and each bag is different, so one bag must have $2 in it.
 can now make $3, but can’t make $4, so the third bag must have $4 in it.
With $1, $2 and $4 in three bags, can make every total up to $7. The last bag has the rest of his money in it – $8.

so the answer is $[1,2,4,8]

wondering how to do this with maple procedure. unsurprisingly my code doesn't work

 

 

Please Wait...