# ROT-13 transform standard input

The challenge: To read an input of arbitrary length and produce the ROT13 of the input. All characters besides A-Z should be copied to the output verbatim, and case should be preserved if possible.

Any language that can read and write standard streams is fair game.

• The problem shouldn't be a tag, so I removed ROT13, just an FYI – Nick Berardi Jan 27 '11 at 21:18
• Don't you mean A-Za-z (to count both upper- and lower-case) ? – Joey Adams Jan 27 '11 at 21:33
• @Chris Jester-Young, it belongs to this category at wikipedia. It's part of cryptography, just not the hardest one. Anyway, I'm not longer following this site. Community dissapointed me. Sorry. GL HF. – Nakilon Jan 30 '11 at 18:59
• Saying xor is not encryption is like saying a+b is not math. – Nakilon Jan 30 '11 at 19:02
• Tags are used to categorize questions and help search similar questions. The cryptography tag (from Greek kryptós, "hidden, secret"; and graphein, "writing") in particular is for encryption and decryption problems. All encryption and decryption, not only those that are secure for modern applications. – Angs Dec 3 '16 at 10:33

# pyg-i - 76 Bytes

P(STDI.read().t({a:a-13 if(77<a<91)or a>109 else a+13 for a in M(ord,STl)}))


Python Equivient:

import sys,string
print(sys.stdin.read().translate({a:a-13 if(77<a<91)or a>109 else a+13 for a in map(ord,string.ascii_letters)}))

• Invalid because the interpreter is not available. – cat Feb 22 '16 at 21:29
• @cat Somehow I got the url wrong. It is fixed now. – Ian D. Scott Feb 23 '16 at 23:24

## Python: 60 bytes

lambda s:''.join([chr((ord(c.lower())-84)%26+97)for c in s])


The only thing I don't like is having that .lower() in there. Any suggestions?

edit: I can get rid of the .lower(), and handle capitals better, but it's 94 bytes now:

lambda s:''.join([chr((ord(c)-(52if ord(c)<97else 84))%26+(65if ord(c)<97else 97))for c in s])


# Jolf, noncompeting (language postdates challenge)

Jolf, 3 bytes

Try it here!

,Ri
,R  rot13
i the input


Or, with new implicit input, ,R.

I'm sorry, but I'm not. I implemented this because it appears often in code-breaking puzzles, which I use Jolf a lot for, and recently used in an ARG. \o/

A longer one (try that one here):

ρi"[%]"γpWpud.pWp2pu+t3 iγH
ρi                           regex replace input
"[%]"                      "[...]" following
pWpu                 "abc...xyzABC....XYZ"
γ                     γ = that
d                functional replace
.         _iγH  the index on the alphabet that the element is
p2pu         shift uppercase alphabet
+t3      over thirteen
pW             upper + lower of that


# C#, 94 bytes

s=>{var r="";foreach(var c in s)r+=(char)(Char.IsLetter(c)?(c|32)<110?c+13:c-13:c);return r;};


Anonymous function which returns the string of characters rotated by 13 places, based on this C answer from Fors. Works for any lower or upper letters while keeping other input the same.

Full program with ungolfed method and test cases:

using System;

namespace ROT13
{
class Program
{
static void Main(string[] args)
{
Func<string, string> f =
s =>
{
var r = "";
foreach (var c in s)
r += (char)(Char.IsLetter(c) ? (c | 32) < 110 ? c + 13 : c - 13 : c);
return r;
};

Console.WriteLine(f("TOO MANY SECRETS!"));   // GBB ZNAL FRPERGF!
Console.WriteLine(f("too many secrets!"));   // gbb znal frpergf!
Console.WriteLine(f("gbb znal frpergf!"));   // too many secrets!
Console.WriteLine(f("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,./"));
// NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm1234567890,./
}
}
}


# Befunge-93, 72 67 bytes

Edit: -5 bytes thanks to James Holderness

<,<v!:+*"a"*""\\"{":\*"G"*"@"\\"[":::_@#+1:~
+0|_\"N"%6-55*1+%


Try it online!

Kinda disappointed in the previous Befunge answers, so I wrote one with much less whitespace.

# Powershell, 77 bytes

-join($args|% t*y|%{[char]((("$_"-match'[a-m]')-("$_"-match'[n-z]'))*13+$_)})


Test script:

$f = { -join($args|% t*y|%{[char]((("$_"-match'[a-m]')-("$_"-match'[n-z]'))*13+$_)}) } @( ,("Hello!","Uryyb!") ,("HELLO","URYYB") ,("URYYB","HELLO") ,("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz","NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm") ,("Why did the chicken cross the road? Gb trg gb gur bgure fvqr!", "Jul qvq gur puvpxra pebff gur ebnq? To get to the other side!") ) | % {$s,$expected =$_
$result = &$f $s "$($result-eq$expected): $result" }  Output: True: Uryyb! True: URYYB True: HELLO True: NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm True: Jul qvq gur puvpxra pebff gur ebnq? To get to the other side!  # Julia 1.0, 69 bytes (x->(c=Char(x);print(c+isletter(c)*13*(-1)^(x&31>13)))).(read(stdin))  Try it online! ### Explanation Most of the code is an anonymous function that takes an integer codepoint and prints the corresponding ROT-13'd character: x->(c=Char(x);print(c+isletter(c)*13*(-1)^(x&31>13))) x->( ) # Anonymous function of x c=Char(x); # Cast x to Char and save as c c+ # Start with c and add to its codepoint: isletter(c)* # If c is not a letter, the rest of this is # multiplied by 0 13*(-1)^( ) # 13, times +/- 1 according to: x&31>13 # Low 5 bits of x are greater than 13 # I.e. x > 'M' (if x is uppercase) or x > 'm' # (if x is lowercase) print( ) # Output the resulting character  We then apply this function, vectorized, to the array of (integer) codepoints returned by read(stdin). # LispLisp (16,636) I'm sorry. ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) (lisp lisp)) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)))) (lisp (lisp (lisp lisp)))))))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp lisp))))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp lisp))))))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp lisp))) (lisp lisp))))))) ((lisp (lisp (lisp lisp))) (((((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) ((((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp)))))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) (lisp lisp)))))) (lisp (lisp (lisp lisp))))) ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) ((((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (lisp lisp)) ((((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) (lisp lisp)))))) (lisp (lisp (lisp lisp)))))))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) (lisp lisp)) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) (lisp lisp)))))) (lisp (lisp (lisp lisp)))))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) (lisp lisp)))))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) ((((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (lisp lisp))))) ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) (lisp lisp)) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) ((((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (lisp lisp))))) ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) (lisp lisp)) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (lisp lisp))))) ((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))))))))) (lisp (lisp (lisp lisp))))))) ((((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (lisp lisp))))) ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) (lisp lisp)) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp lisp))))))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp lisp))) (lisp lisp))))))) ((lisp (lisp (lisp lisp))) (((((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (lisp lisp))))) ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) (lisp lisp)) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) (lisp lisp)))))) (lisp (lisp (lisp lisp))))) (((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) (lisp lisp)) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)))) (lisp (lisp (lisp lisp)))))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp lisp))))))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) (lisp lisp))))) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (lisp (lisp (lisp lisp)))))))))) ((lisp (lisp (lisp lisp))) (lisp lisp)))))))))))) (lisp (lisp (lisp lisp)))))))))))) (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp lisp)))))))))) (((lisp (lisp (lisp (lisp lisp)))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp (lisp lisp)))))) (((lisp (lisp (lisp (lisp lisp)))) ((lisp (lisp (lisp lisp))) (lisp (lisp (lisp lisp))))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) (lisp lisp))))) ((lisp (lisp (lisp lisp))) (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp)) ((lisp (lisp (lisp lisp))) ((lisp (lisp (lisp lisp))) (lisp lisp))))))))  • Is this an actual language with an implementation? If so, can you please link to it? – Jo King Apr 7 at 8:04 • @JoKing Wikipedia TIO – Benjamin Urquhart Apr 7 at 17:39 • @BenjaminUrquhart Yes, Lisp is a language. Lisplisp however, I have found no evidence exists – Jo King Apr 7 at 21:33 • @JoKing oh I see. Maybe he was referring to this? – Benjamin Urquhart Apr 7 at 22:23 • @BenjaminUrquhart No, that's just another Lisp interpreter – Jo King Apr 7 at 22:34 # 8086 Machine Code, 27 bytes Listing: ROT13 MACRO STLOOP: AC LODSB ; load byte from SI into AL, advance SI 8B D0 MOV DX, AX ; save original char in DL 0C 20 OR AL, 020H ; lowercase the char 3C 61 CMP AL, 'a' ; is char less than 'a'? 7C 0F JL STCHR ; if so, do not convert 3C 7A CMP AL, 'z' ; is char greater than 'z'? 7F 0B JG STCHR ; if so, do not convert B6 0D MOV DH, 13 ; add or subtract 13 3C 6E CMP AL, 'n' ; is char less than 'n'? 7C 02 JL ADD13 ; if so, add positive 13 F6 DE NEG DH ; otherwise add -13 ADD13: 92 XCHG AX, DX ; original char back to AL 02 C4 ADD AL, AH ; add 13 or -13 to original char STCHR: AA STOSB ; store converted byte into DI, advance DI E2 E5 LOOP STLOOP ; continue loop through string ENDM  Implemented as a MACRO (function), input string in SI, length in CX. Output string in DI. Test IBM PC DOS program output: Download R13.COM test program (PC DOS). ## Scala 108 def m(a:Int,z:Int,c:Int)=if(c>=a&&c<z)a+((c-a+13)%26)else c "Ok?".map(c=>print(m(65,91,m(97,123,c)).toChar))  ungolfed: def m (a: Int, z:Int, c:Int) = if (c >= a && c <= z) a+((c-a+13)%26) else c "Ok?".foreach (c => print (m ('A', 'Z', m ('a', 'z', c)).toChar))  result: Bx?  Mathematica 102 StringReplace[Input[], Join@@Table[Rule@@FromCharacterCode/@{i+c,Mod[i+13,26]+c},{c,{65,97}},{i,0,25}]]  # Haskell (103) Reused maybe c id$ lookup c from jloy's answer.

main=interact$map(\c->maybe c id$lookup c\$[['a'..'z'],['A'..'Z']]>>=zip<*>uncurry(flip(++)).splitAt 13)


# Scala (96 chars)

def r(s:String)=s.map{c⇒val m = if(c<91)65 else 97
if(c.isLetter)
((c+13-m)%26+m).toChar
else c}


# J, 32 29 bytes

a.{~3&u:+13*2|&.>:'@MZmz'&I.


Try it online!

# Jelly, 13 bytes

ØAṙ13żµ;ŒlZyɠ


Try it online!

Still one byte away from 05AB1E ლ(ಠ益ಠლ). Weirdest way I've ever defined a Jelly link, but it works. Takes the string via STDIN (no shorter than taking an ARGV, in this instance)

## How it works

ØAṙ13żµ;ŒlZyɠ - Main link. No arguments
ØA            - Yield the upper case alphabet               ["A", "B",   ... "Y", "Z"]
ṙ13         - Rotate by 13 units left                     ["N", "O",   ... "L", "M"]
ż        - Zip with alphabet. Call this X              [["N", "A"], ... ["M", "Z"]]
µ       - Begin a monadic chain with X as argument
Œl    - X lowercased                                [["n", "a"], ... ["m", "z"]]
;      - Concatenate with X                          [["N", "A"], ... ["m", "z"]]
Z   - Transpose rows and columns                  [["N", ... "m"], ... ["A", ... "z"]]
ɠ - Yield a line from STDIN. Call this Y        "Hello, World!"
y  - Transliterate Y based on the mapping in Y   "Uryyb, Jbeyq!"


A lot of the work here is done by the y atom. This is a dyad whose arguments are broken up as follows:

• Left argument: A two element array, consisting of the following elements:
• Characters to be changed from.
• Characters to be changed into.
• Right argument: Character array to transliterate

This is a good example of how it works.

In the right argument (the character array), it replaces each occurrence of a key in the left argument (the mapping) with the corresponding result. Any characters that aren't a key are just left alone.

One of the key things to grasp is that y doesn't take the mapping in [key, result] pairs. Instead, it takes the list as a transposition of these pairs, so the pairs

[['a', 'b'], ['c', 'd'], ['e', 'f']]


to translate a to b, c to d etc. would be represented as

[['a', 'c', 'e'], ['b', 'd', 'f']]


in order to use y. When using y, if no result is produced and STDERR has an error message, try prepending a Z, to make Zy, and see if that works.

# Retina, 13 bytes

13+TzlZLl_L


Try it online!

The straightforward transliteration that directly applies ROT13 would be 2 bytes longer Try it online!

### Explanation

The transliteration stage here is wrapped in a loop stage making it run 13 times (or until the string is not transformed anymore, which can only happen if the input string has no alphabetic characters).

In the transliteration, characters in zlZL are transformed into the characters at the same positions in l_L. Here, z and Z are exactly what they look like, while l and L get converted into the lowercase and uppercase alphabets. The final letters of those alphabets are ignored because they already appear earlier in the string, and _ is just a placeholder to make the uppercase alphabet line up correctly. The result is transforming each letter into the next one (a->b,b->c,...,z->a); doing this 13 times is ROT13.

# Python 3, 70 bytes

a=input()
for i in a:print(end=i.isalpha()*chr(65+(ord(i)-52)%26)or i)

• Your proposed solution does not work with lowercase letters. It's not explicitely specified in the challenge though, so I'm not sure if your answer is valid. – Nathan.Eilisha Shiraini Feb 27 at 18:17

# Japt, 28 bytes

c_d)è"%l")?Z|H)<#n?Z+D:Z-D:Z


Try it!

c_d)è"%l")?Z|H)<#n?Z+D:Z-D:Z
c_                                # map input string through a function
d)è"%l")?                       # regex check if current character is a letter
Z|H)<#n?               # is it less than the letter n?
Z+D:           # if yes, then add 13
Z-D:       # otherwise, subtract 13
Z      # not a letter, do not transform

• 20 bytes using replace and switching to v2.0a1. There must be a shorter way, though. – Shaggy Feb 27 at 17:42
• 18 bytes – Shaggy Feb 27 at 17:45
• Nice - I had not tried the beta version yet. Looks like regex may have improved? – dana Feb 27 at 17:47
• Yeah, but it's bugged to hell at the moment - only single character class work; anything wrapped in / won't. – Shaggy Feb 27 at 17:50
• – Shaggy Feb 27 at 17:50

# T-SQL, non-competing (language postdates challenge)

The TRANSLATE function was introduced in SQL Server 2017.

Input is taken from the column I of the table T.

SELECT TRANSLATE(I,A+B,B+A)FROM(VALUES('ABCDEFGHIJKLM','NOPQRSTUVWXYZ'))V(A,B),T


80 bytes

SQL Fiddle

# PHP - 27 Bytes

<?=str_rot13(fgets(STDIN));


# ///, 217 bytes

/|/\/\///a/n|b/o|c/p|d/q|e/r|f/s|g/t|h/u|i/v|j/w|k/x|l/y|m/z|n/a|o/b|p/c|q/d|r/e|s/f|t/g|u/h|v/i|w/j|x/k|y/l|z/m|A/N|B/O|C/P|D/Q|E/R|F/S|G/T|H/U|I/V|J/W|K/X|L/Y|M/Z|N/A|O/B|P/C|Q/D|R/E|S/F|T/G|U/H|V/I|W/J|X/K|Y/L|Z/M/


Because /// have no input, the input is appended to the end of the program. I have seen another answer done so, but forgot where.

Try It Online!

Note that the program is so slow that it takes more than 60s to run and thus will not do the work in the link.

New contributor
TwilightSparkle is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• Welcome to the site! Would it be possible for you to edit in a link to an online interpreter, such as Try It Online!, so that other users may verify your answer? – caird coinheringaahing 23 hours ago
• @cairdcoinheringaahing thanks! I will. – TwilightSparkle 23 hours ago
• There is as problem: the program is too slow that it takes more than 60s to run. – TwilightSparkle 23 hours ago
• That's fine, just mention that in your post, along with the link – caird coinheringaahing 23 hours ago
• I dunno, are you sure this isn't jist running into an infinite loop somewhere? Surely it can't be that inefficient that it takes more than 60 seconds to run, even on an empty input – Jo King 22 hours ago