Encode with ROT13.5 [FINALIZED]
+1
−0
Now posted: Encode with ROT13.5
Given a string, convert all of its letters using ROT13, and all of its digits using ROT5. This is sometimes referred to as ROT13.5.
Input
- A sequence of printable ASCII characters (character codes 32 to 126 inclusive)
- This may be a string or any data structure of characters
Output
- A sequence of characters
- This may be a string or any ordered data structure of characters. It does not need to match the input format (provided it is consistent between inputs)
- For example, you may take input as an array of characters, and output as a string, provided this format does not change for different inputs
- Each character in the output will be determined by the character in the corresponding position in the input, as follows:
- A lower case letter will be replaced with the lower case letter 13 character codes after it, wrapping back to 'a' if 'z' is exceeded
- An upper case letter will be replaced with the upper case letter 13 character codes after it, wrapping back to 'A' if 'Z' is exceeded
- A numeric digit will be replaced with the numeric digit 5 character codes after it, wrapping back to '0' if '9' is exceeded
- Any other character will remain unchanged
Conversion table
Here is the output character for every valid input character, in the format input : output
(the first character is a space, which remains unchanged):
:
! : !
" : "
# : #
$ : $
% : %
& : &
' : '
( : (
) : )
* : *
+ : +
, : ,
- : -
. : .
/ : /
0 : 5
1 : 6
2 : 7
3 : 8
4 : 9
5 : 0
6 : 1
7 : 2
8 : 3
9 : 4
: : :
; : ;
< : <
= : =
> : >
? : ?
@ : @
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
{ : {
| : |
} : }
~ : ~
Test cases
Test cases are in the format "input string" : "output string"
.
"gnat irk terra" : "tang vex green"
"2468" : "7913"
"#%&@,.:;?" : "#%&@,.:;?"
"Rot13.5 & Ebg68.0" : "Ebg68.0 & Rot13.5"
Explanations are optional, but I'm more likely to upvote answers that have one.
0 comment threads