Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
First off - if you feel the question is un-ethical - fair enough - I am inclined to agree, but this is still an interesting question to which perl I belive is ideally suited - so, disclaimer aside, here is what I would like to achieve:

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 '


In reply to Character Combinations by viGuy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-19 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found