Reverse the alphabet so that abc => zyx
and ABC => ZYX
Examples:
("code") => "xlwv"
("Golf") => "Tlou"
("1Avva8TT") => "1Zee8GG"
^You can assume that you will always recieved a valid string
Reverse the alphabet so that abc => zyx
and ABC => ZYX
Examples:
("code") => "xlwv"
("Golf") => "Tlou"
("1Avva8TT") => "1Zee8GG"
^You can assume that you will always recieved a valid string
Language: Javascript
Length: 67
Solution:
_=>_.replace(/[A-Z]/gi,$=>String.fromCharCode($.charCodeAt()+4^31))
Language: PHP
Length: 76
Solution:
function r($x){$l=str_split($x);foreach($l as $i){echo chr(ord($i)+4^31);}}
Language: PHP (v5.4 — deprecated use of /e
modifier)
Length: 73
Solution:
function r($w){return preg_replace('/[a-z]/ei','chr(ord(\\0)+4^31)',$w);}
or 50 characters without the function()
wrapping:
preg_replace('/[a-z]/ei','chr(ord(\\0)+4^31)',$w);
Language: Python 2.7
Length: 51
Solution:
f=lambda s:`map(lambda x:chr(31^4+ord(x)),s)`[2::5]
Language: C
Length: 147
Solution: