Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Here's my answer, FWIW, but it's not to the question in topic :). I was playing with idea of packing encoding information as tightly as possible, bit vectors, as "5 bits of code per letter", this avenue to explore. Of course, in the end it turned out to be longest among all solutions here, so no need to post it.

But, what if letters are coded as random numbers e.g. up to 1000? With 26 random 3-digit numbers (code to generate this encoding is obvious, not shown), and based on Eily's answer, solution could be:

$_ = 'NDDDDTSVCLGTRQCSWFAGCTNRTWNSSA 0'; my @F = split ''; @h{A..Z}=('27941492412912434962583369414978036693514585011981639390315 +1901525290851349853' =~/.../g);say"@h{@F}";

Now, my idea (here with 10 bits per code) is becoming competitive, length-wise:

@h{A..Z}=map 1023& Math::BigInt->from_base(D3PghSS0AZyLfhkL67kHFiuXWoB +6p9GUkgznoeEO1eNj, 62)>>10*$_,0..25;say"@h{@F}";

It's still slightly longer, and I need to use the module. I think, if number of symbols grows (e.g., 52 letters and 10 digits i.e. 62), then this solution will scale better and better :)


In reply to Re: A little golfing challenge: Replacing letters with numbers by vr
in thread A little golfing challenge: Replacing letters with numbers by haukex

Title:
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?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (6)
    As of 2020-11-27 17:18 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?