viGuy has asked for the wisdom of the Perl Monks concerning the following question:
What would be the most efficient way to produce every possible combination of a given set of charactors in a string?
Here are my thoughts so far:
Using hashes - I belive these to be more efficient than arrays - one hash assigned to each charactor in the string. The hash would contain the possible charactor values with incremental numbers for the key values.
E.G: For the first charactor in the string I would have a hash of:
key-value,A-1,B-2,C-3
for the second charactor in the string I would have a hash of:
a-1,b-2,c-3
So for the first iteration I would call hash1{key1} hash2{key1}
for the second iteration I would call hash1{key2} hash2{key1}
etc
Now you know and I know how this could be applied - but there are plenty of "off the site" products out there that I could use to achieve the same thing. This is more for 'fun' to figure out how to do this EFFICIENTLY in perl. So - what do you think? How would you approach this?
20030823 Edit by jeffa: Changed title from 'Charactor Combinations '
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Character Combinations
by Limbic~Region (Chancellor) on Aug 22, 2003 at 22:02 UTC | |
Re: Character Combinations
by graff (Chancellor) on Aug 22, 2003 at 22:44 UTC | |
Re: Character Combinations
by antirice (Priest) on Aug 23, 2003 at 01:33 UTC | |
Re: Character Combinations
by esh (Pilgrim) on Aug 23, 2003 at 06:53 UTC | |
Re: Character Combinations
by viGuy (Initiate) on Aug 22, 2003 at 21:51 UTC | |
Re: Character Combinations
by chunlou (Curate) on Aug 22, 2003 at 23:00 UTC | |
by Limbic~Region (Chancellor) on Aug 22, 2003 at 23:06 UTC | |
|