in reply to A little golfing challenge: replace digits by random letters
have you decided to consume all our spare times!?! ;)
Not golfed but maybe of interest
WebPerl link (requires haukex ;)perl '-M0;map{$h{$_}++}97..122;@a=map{chr$_}keys%h;$"=""' -pe 'eval"tr +/0-9/@a[0..9]/"' input.txt
L*
UPDATE see it running
perl '-M0;$h{$_}++for 97..122;$"=""' -pe 's/(\d)/(map{chr$_}keys%h)[$1]/eg' input.txt
removing unneeded assignemnts..
perl '-M0;$h{$_}++for 97..122' -pe 's/(\d)/(map{chr$_}keys%h)[$1]/eg' input.txt
or even..
perl '-M0;@h{97..122}=1x125' -pe 's/(\d)/(map{chr$_}keys%h)[$1]/eg' input.txt
perl '-M0;@h{97..122}=1x125'-pe 's/\d/(map{chr$_}keys%h)[$&]/eg' input.txt
perl '-M0;@h{97..122}=1x125'-pe 's/\d/chr((keys%h)[$&])/eg' input.txt
perl '-M0;undef@h{97..122}'-pe 's/\d/chr((keys%h)[$&])/eg' input.txt
perl '-M0;@h{97..122}=1'-pe 's/\d/chr((keys%h)[$&])/eg' input.txt
L*
congrats Eily for the below reduction!
another variation, not highly random..
perl -pe 's/\d/(a..z)[$&-(split"",time)[-1]]/eg' input.txt
or.. (shorter than Eily's one ;)
perl -pe 's|\d|(a..z)[$&-time%7]|eg' input.txt
perl -pe 's|\d|(a..z)[$&-$^T%7]|eg' input.txt
L*
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A little golfing challenge: replace digits by random letters (updated) -- oneliner
by Eily (Monsignor) on Feb 10, 2019 at 20:24 UTC | |
|
Re^2: A little golfing challenge: replace digits by random letters (updated) -- oneliner
by Eily (Monsignor) on Feb 11, 2019 at 14:23 UTC | |
by haukex (Archbishop) on Feb 11, 2019 at 14:26 UTC |