If you can work with just pairings then a lookup table is very fast.
my @list =( 10, 5, 13, 3, 15, 1 ); my $total = 16; my %lookup; @lookup{@list} = (); for my $val( @list ) { my $need = $total -$val; next unless exists $lookup{$need}; print "Found $val + $need = $total\n"; delete $lookup{$val}; }
cheers
tachyon
In reply to Re: amount permutations
by tachyon
in thread amount permutations
by gr0k
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |