in reply to Re: Algorithm to convert combinations to bitstring
in thread Algorithm to convert combinations to bitstring
Keep in mind that the goal would be to have a known set ( say 'A' .. 'Z') and a known subset size (say 5). Then, given a valid subset of the specified size (say AMTXZ), determine if that subset has been "seen" before. If not, perform some action and then mark it as being "seen". Here is some starter code to give you an idea of what I have already accomplished:
my @set = 'A' .. 'Z'; my $subset_size = 5; my @subset = qw/A M T X Z/; process_subset(@subset); process_subset(@subset); sub process_subset { if (seen(@_)) { print "Already processed '@_'\n"; return; } print "Performing expensive operation on '@_'\n"; set_seen(@_); } sub seen { # For you to implement # ... } sub set_seen { # For you to implement # ... }
Keep in mind that @set, @subset_size and @subset are all subject to change - so it has to be a general purpose solution.
Cheers - L~R
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Algorithm to convert combinations to bitstring
by spx2 (Deacon) on Jan 01, 2010 at 06:50 UTC | |
by Limbic~Region (Chancellor) on Jan 01, 2010 at 19:49 UTC | |
by spx2 (Deacon) on Jan 10, 2010 at 14:57 UTC | |
by Limbic~Region (Chancellor) on Jan 10, 2010 at 15:26 UTC |