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 '