Details
Name Kata: ROT13
5kuy
Description: How can you tell an extrovert from an introvert at NSA? Va gur ryringbef, gur rkgebireg ybbxf ng gur BGURE thl'f fubrf.
I found this joke on USENET, but the punchline is scrambled. Maybe you can decipher it? According to Wikipedia, ROT13 is frequently used to obfuscate jokes on USENET.
Hint: For this task you're only supposed to substitue characters. Not spaces, punctuation, numbers etc.
Example:
"EBG13 rknzcyr." --> "ROT13 example." "This is my first ROT13 excercise!" --> "Guvf vf zl svefg EBG13 rkprepvfr!"
My Solutions
JavaScript
const rot13 = (str) => { return str.replace(/[a-z]/giu, (x) => { return String.fromCharCode( x.charCodeAt() + ( x.toLowerCase() <= 'm' ? 13: -13 )); }); }
Python
def rot13(message: str) -> str: rot13 = bytes.maketrans( b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", b"nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" ) return message.translate(rot13)
Top comments (0)