Skip to content

Commit 4879a46

Browse files
Fix number of rotations N as 13 (Resolves TheAlgorithms#12306)
1 parent 52602ea commit 4879a46

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: ciphers/rot13.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def dencrypt(s: str, n: int = 13) -> str:
1+
def dencrypt(s: str) -> str:
22
"""
33
https://en.wikipedia.org/wiki/ROT13
44
@@ -9,12 +9,13 @@ def dencrypt(s: str, n: int = 13) -> str:
99
>>> dencrypt(s) == msg
1010
True
1111
"""
12+
N = 13
1213
out = ""
1314
for c in s:
1415
if "A" <= c <= "Z":
15-
out += chr(ord("A") + (ord(c) - ord("A") + n) % 26)
16+
out += chr(ord("A") + (ord(c) - ord("A") + N) % 26)
1617
elif "a" <= c <= "z":
17-
out += chr(ord("a") + (ord(c) - ord("a") + n) % 26)
18+
out += chr(ord("a") + (ord(c) - ord("a") + N) % 26)
1819
else:
1920
out += c
2021
return out

0 commit comments

Comments
 (0)