in reply to Re: A little golfing challenge: replace digits by random letters (updated) -- oneliner
in thread A little golfing challenge: replace digits by random letters
or.. (shorter than Eily's one ;)That's nearly always correct (if you ignore the fact that it's a shift, not a shuffle). You'll get different values if the lines are not treated in the same second. This would happen if the first line is handled at 9:59:59.9999 and the second at 10:00:00.0000 (add the proper number of digits). Or if you are working on a piped input from a slow program, or the input is big enough. This can be demonstrated by adding a sleep.
perl -pe 's|\d|(a..z)[$&-time%7]|eg' input.txt
I realized I could shorten the other version (I don't feel like calling it mine when I just took your idea and rewrote it :P), but it's still longer than your latest proposition:
perl -pe '@h{a..z}=1;s/\d/(%h)[$&*2]/eg' input.txt
Because since this is golfing, why would you bother doing things properly/efficiently? :P
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: A little golfing challenge: replace digits by random letters (updated) -- oneliner
by haukex (Archbishop) on Feb 11, 2019 at 14:26 UTC |