in reply to amount permutations
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: amount permutations
by gr0k (Novice) on Mar 04, 2004 at 19:13 UTC |