Puzzle: Rot13 [reference]

Rot13” is a coding puzzle that people can be attempted in the following languages: ruby, haskell, python, javascript, shell, elixir, csharp, c, crystal, nasm, cpp, purescript, rust, and r.

  • Difficulty: 5 kyu
  • Stars: 840
  • Votes: 2531
  • Category: reference
  • Tags: Fundamentals, Ciphers, Algorithms, Cryptography, Logic, Security
  • Source: codewars

Description

ROT13 is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet. ROT13 is an example of the Caesar cipher.

Create a function that takes a string and returns the string ciphered with Rot13.
If there are numbers or special characters included in the string, they should be returned as they are. Only letters from the latin/english alphabet should be shifted, like in the original Rot13 “implementation”.

if:python
Please note that using `encode` is considered cheating.

if:r
**Note:** As R is a natively vectorized language, you should write `rot13()` such that the argument `x` may be a character vector of any length. The return value should always be a character vector of the same length as `x`.

Solve It Here

Click the link below to solve it on Codewars:

Notes

This puzzle was posted by a Slackbot via a slash command. If you want to help work on the app, send a message to @Josh.

If you don’t want to see the coding puzzles when you visit the forum, you can go into your settings and mute the puzzles category.