mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-03-30 18:36:43 +00:00
Fix number of rotations N
as 13 (Resolves TheAlgorithms#12306)
This commit is contained in:
parent
52602ea5b6
commit
4879a46be1
@ -1,4 +1,4 @@
|
||||
def dencrypt(s: str, n: int = 13) -> str:
|
||||
def dencrypt(s: str) -> str:
|
||||
"""
|
||||
https://en.wikipedia.org/wiki/ROT13
|
||||
|
||||
@ -9,12 +9,13 @@ def dencrypt(s: str, n: int = 13) -> str:
|
||||
>>> dencrypt(s) == msg
|
||||
True
|
||||
"""
|
||||
N = 13
|
||||
out = ""
|
||||
for c in s:
|
||||
if "A" <= c <= "Z":
|
||||
out += chr(ord("A") + (ord(c) - ord("A") + n) % 26)
|
||||
out += chr(ord("A") + (ord(c) - ord("A") + N) % 26)
|
||||
elif "a" <= c <= "z":
|
||||
out += chr(ord("a") + (ord(c) - ord("a") + n) % 26)
|
||||
out += chr(ord("a") + (ord(c) - ord("a") + N) % 26)
|
||||
else:
|
||||
out += c
|
||||
return out
|
||||
|
Loading…
x
Reference in New Issue
Block a user