mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-01 11:26: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
|
https://en.wikipedia.org/wiki/ROT13
|
||||||
|
|
||||||
@ -9,12 +9,13 @@ def dencrypt(s: str, n: int = 13) -> str:
|
|||||||
>>> dencrypt(s) == msg
|
>>> dencrypt(s) == msg
|
||||||
True
|
True
|
||||||
"""
|
"""
|
||||||
|
N = 13
|
||||||
out = ""
|
out = ""
|
||||||
for c in s:
|
for c in s:
|
||||||
if "A" <= c <= "Z":
|
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":
|
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:
|
else:
|
||||||
out += c
|
out += c
|
||||||
return out
|
return out
|
||||||
|
Loading…
x
Reference in New Issue
Block a user