Fix sphinx/build_docs warnings for ciphers (#12485)

* Fix sphinx/build_docs warnings for ciphers

* Fix
This commit is contained in:
Maxim Smolskiy
2024-12-30 12:56:24 +03:00
committed by GitHub
parent 94b3777936
commit f45e392cf6
7 changed files with 170 additions and 125 deletions

View File

@ -1,9 +1,11 @@
def remove_duplicates(key: str) -> str:
"""
Removes duplicate alphabetic characters in a keyword (letter is ignored after its
first appearance).
first appearance).
:param key: Keyword to use
:return: String with duplicates removed
>>> remove_duplicates('Hello World!!')
'Helo Wrd'
"""
@ -18,6 +20,7 @@ def remove_duplicates(key: str) -> str:
def create_cipher_map(key: str) -> dict[str, str]:
"""
Returns a cipher map given a keyword.
:param key: keyword to use
:return: dictionary cipher map
"""
@ -43,9 +46,11 @@ def create_cipher_map(key: str) -> dict[str, str]:
def encipher(message: str, cipher_map: dict[str, str]) -> str:
"""
Enciphers a message given a cipher map.
:param message: Message to encipher
:param cipher_map: Cipher map
:return: enciphered string
>>> encipher('Hello World!!', create_cipher_map('Goodbye!!'))
'CYJJM VMQJB!!'
"""
@ -55,9 +60,11 @@ def encipher(message: str, cipher_map: dict[str, str]) -> str:
def decipher(message: str, cipher_map: dict[str, str]) -> str:
"""
Deciphers a message given a cipher map
:param message: Message to decipher
:param cipher_map: Dictionary mapping to use
:return: Deciphered string
>>> cipher_map = create_cipher_map('Goodbye!!')
>>> decipher(encipher('Hello World!!', cipher_map), cipher_map)
'HELLO WORLD!!'
@ -70,6 +77,7 @@ def decipher(message: str, cipher_map: dict[str, str]) -> str:
def main() -> None:
"""
Handles I/O
:return: void
"""
message = input("Enter message to encode or decode: ").strip()