in reply to A little golfing challenge: Replacing letters with numbers
The trick with golfing is to wait for Discipulus to have a good idea and steal it from him :P.
Only works on Linux because it needs double quote context (so you would need two extra chars on windows).perl -nF -E '@h{split"",ARNDBCEQZGHILKMFPSTWYV}=1..22;say"@h{@F}"'
Edit: with the corresponding link
Edit 2: removed the -la options. I don't use -l with say, and -a is implied by -F
Edit 3: shorter than split:
perl -nF -E '@h{ARNDBCEQZGHILKMFPSTWYV=~/./g}=1..22;say"@h{@F}"'
Edit 4: -a is not implied by -F in perl v5.10 though
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A little golfing challenge: Replacing letters with numbers (edited)
by rsFalse (Chaplain) on Feb 21, 2019 at 15:54 UTC | |
by Eily (Monsignor) on Feb 22, 2019 at 11:06 UTC |