Created
April 29, 2017 04:19
-
-
Save arodland/c061dd7b0207a9b77a768391c3ff3e64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# starting length: 96 | |
@a=("Hare ","Krishna ","Rama ","\n");foreach(split//,'ababdbbaadacacdccaad'){print $a[ord($_)-97]} | |
# unneeded whitespace (-1) | |
@a=("Hare ","Krishna ","Rama ","\n");foreach(split//,'ababdbbaadacacdccaad'){print$a[ord($_)-97]} | |
# magic variable substitution (-2) | |
@a=("Hare ","Krishna ","Rama ",$/);foreach(split//,'ababdbbaadacacdccaad'){print$a[ord($_)-97]} | |
# for is the same as foreach (-4) | |
@a=("Hare ","Krishna ","Rama ",$/);for(split//,'ababdbbaadacacdccaad'){print$a[ord($_)-97]} | |
# /./g is shorter than split (-2) | |
@a=("Hare ","Krishna ","Rama ",$/);for('ababdbbaadacacdccaad'=~/./g){print$a[ord($_)-97]} | |
# we don't need this ord business... make the characters of the string be indices! (-8) | |
@a=("Hare ","Krishna ","Rama ",$/);for('01013110030202322003'=~/./g){print$a[$_]} | |
# nor do we need a variable... (-5) | |
for('01013110030202322003'=~/./g){print+("Hare ","Krishna ","Rama ",$/)[$_]} | |
# postfix 'for' doesn't need parens or braces (-4) | |
print+("Hare ","Krishna ","Rama ",$/)[$_]for'01013110030202322003'=~/./g | |
# new length: 72 (-26) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment