DEV Community

Qroia FAK(C)E
Qroia FAK(C)E

Posted on

Codewars Challenge Day 4: ROT13


Name Kata: ROT13
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.

"EBG13 rknzcyr." -->
"ROT13 example."

"This is my first ROT13 excercise!" -->
"Guvf vf zl svefg EBG13 rkprepvfr!"
Enter fullscreen mode Exit fullscreen mode

My Solutions


const rot13 = (str) => {
  return str.replace(/[a-z]/giu, (x) => {
    return String.fromCharCode(
      x.charCodeAt() + (
        x.toLowerCase() <= 'm' ? 13: -13
Enter fullscreen mode Exit fullscreen mode


def rot13(message: str) -> str:
    rot13 = bytes.maketrans(
    return message.translate(rot13)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)