Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Encode with ROT13.5

+4
−0

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.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

4 answers

You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.

+0
−0

Stax, 15 bytes

⌐♪aù¢φσX▀┼╜°«↕j

Run and debug it

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Python 3, 145 bytes

lambda s:[dict({chr(i+c):chr((i+13)%26+c)for i in range(26)for c in(65,97)},**{chr(i+48):chr((i+5)%10+48)for i in range(10)}).get(c,c)for c in s]

Try it online!

Generates and concatonates 2 dicts:

{chr(i+c):chr((i+13)%26+c)for i in range(26)for c in(65,97)} -> {'A': 'N', 'a': 'n', 'B': 'O', 'b': 'o', 'C': 'P', 'c': 'p', 'D': 'Q', 'd': 'q', 'E': 'R', 'e': 'r', 'F': 'S', 'f': 's', 'G': 'T', 'g': 't', 'H': 'U', 'h': 'u', 'I': 'V', 'i': 'v', 'J': 'W', 'j': 'w', 'K': 'X', 'k': 'x', 'L': 'Y', 'l': 'y', 'M': 'Z', 'm': 'z', 'N': 'A', 'n': 'a', 'O': 'B', 'o': 'b', 'P': 'C', 'p': 'c', 'Q': 'D', 'q': 'd', 'R': 'E', 'r': 'e', 'S': 'F', 's': 'f', 'T': 'G', 't': 'g', 'U': 'H', 'u': 'h', 'V': 'I', 'v': 'i', 'W': 'J', 'w': 'j', 'X': 'K', 'x': 'k', 'Y': 'L', 'y': 'l', 'Z': 'M', 'z': 'm'} for ROT13

{chr(i+48):chr((i+5)%10+48)for i in range(10)} -> {'0': '5', '1': '6', '2': '7', '3': '8', '4': '9', '5': '0', '6': '1', '7': '2', '8': '3', '9': '4'} for ROT5

It then gets the corresponding item from the concatonated dicts for each character in the input string.

Inputs as a string, outputs as a list

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Vyxal, 16 bytes

kakAkdW₌ṅƛL½Ǔ;ṅĿ

Try it Online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+0
−0

Bash, 31 bytes

tr a-zA-Z0-9 n-za-mN-ZA-M5-90-4

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »