Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

comment on

( #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

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (11)
    As of 2021-01-20 20:06 GMT
    Find Nodes?
      Voting Booth?