Syntactic Confectionery Delight | |
PerlMonks |
Re: A little golfing challenge: Replacing letters with numbersby vr (Curate) |
on Feb 22, 2019 at 11:13 UTC ( [id://1230369]=note: 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:
Now, my idea (here with 10 bits per code) is becoming competitive, length-wise:
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 Section
Seekers of Perl Wisdom
|
|