in reply to Re: check possible combination of sum using given array
in thread check possible combination of sum using given array

you are enumerating the permutations, OP asked for combinations…
  • Comment on Re^2: check possible combination of sum using given array

Replies are listed 'Best First'.
Re^3: check possible combination of sum using given array
by bliako (Abbot) on Jul 08, 2019 at 09:38 UTC

    good point! Converting my program to combinations is trivial. Make sure that children are added to any tree node only if their number is >= than current.

    foreach(@$input){ # add this to make sure that we have combinations rather than permut +ations: next if( defined($v) && $_ < $v->{'number'} ); ...

    for target 35 it yields:

    tr_strictly_perms.pl : here are all the solutions: 1)5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 2)7,2,2,2,2,2,2,2,2,2,2,2,2,2,2 3)5,5,5,2,2,2,2,2,2,2,2,2,2 4)7,5,5,2,2,2,2,2,2,2,2,2 5)7,7,5,2,2,2,2,2,2,2,2 6)7,7,7,2,2,2,2,2,2,2 7)5,5,5,5,5,2,2,2,2,2 8)7,5,5,5,5,2,2,2,2 9)7,7,5,5,5,2,2,2 10)7,7,7,5,5,2,2 11)7,7,7,7,5,2 12)5,5,5,5,5,5,5 13)7,7,7,7,7