in reply to Re^2: Sum of N elements in an M element array
in thread Sum of N elements in an M element array
#!/usr/bin/perl use strict; use warnings; use Algorithm::Permute; my $p = Algorithm::Permute->new(['a','b','c','d','e'], 3); while (my @res = $p->next) { print join("+", @res), "\n"; } __END__ # I just used my editor to sort the output # adapt the above code as you wish a+b+c a+b+d a+b+e a+c+b a+c+d a+c+e a+d+b a+d+c a+d+e a+e+b a+e+c a+e+d b+a+c b+a+d b+a+e b+c+a b+c+d b+c+e b+d+a b+d+c b+d+e b+e+a b+e+c b+e+d c+a+b c+a+d c+a+e c+b+a c+b+d c+b+e c+d+a c+d+b c+d+e c+e+a c+e+b c+e+d d+a+b d+a+c d+a+e d+b+a d+b+c d+b+e d+c+a d+c+b d+c+e d+e+a d+e+b d+e+c e+a+b e+a+c e+a+d e+b+a e+b+c e+b+d e+c+a e+c+b e+c+d e+d+a e+d+b e+d+c
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Sum of N elements in an M element array
by johngg (Canon) on Feb 13, 2020 at 10:38 UTC | |
by Marshall (Canon) on Feb 14, 2020 at 20:32 UTC | |
by AnomalousMonk (Archbishop) on Feb 14, 2020 at 23:25 UTC | |
by Marshall (Canon) on Feb 15, 2020 at 02:26 UTC |