in reply to Re: Sum of N elements in an M element array
in thread Sum of N elements in an M element array
@a=(1..5); my @comb=""; for(my $i=0;$i<=$#a;$i++) { for(my $j=0;$j<=$#a;$j++) { next if $i==$j; if ($a[$i] < $a[$j]) { push @comb, "$a[$i] , $a[$j]" ; } else { push @comb, "$a[$j] , $a[$i]" ; } } } shift @comb; use List::MoreUtils qw(uniq); @comb = uniq(@comb);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Sum of N elements in an M element array
by abhay180 (Sexton) on Feb 02, 2020 at 08:04 UTC |