From b9d0dc44df713daff206f9a9c06be1adb848f15c Mon Sep 17 00:00:00 2001 From: MadhavGupta1506 Date: Sat, 9 Nov 2024 16:42:28 +0530 Subject: [PATCH 1/4] fix-Used-list-instead-of-string-in-rot13.py-and-removed-n --- ciphers/rot13.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ciphers/rot13.py b/ciphers/rot13.py index b367c3215127..34f5b38abd0f 100644 --- a/ciphers/rot13.py +++ b/ciphers/rot13.py @@ -1,4 +1,4 @@ -def dencrypt(s: str, n: int = 13) -> str: +def dencrypt(s: str) -> str: """ https://en.wikipedia.org/wiki/ROT13 @@ -9,7 +9,8 @@ def dencrypt(s: str, n: int = 13) -> str: >>> dencrypt(s) == msg True """ - out = "" + n=13 + out:list[str] = [] for c in s: if "A" <= c <= "Z": out += chr(ord("A") + (ord(c) - ord("A") + n) % 26) @@ -17,16 +18,16 @@ def dencrypt(s: str, n: int = 13) -> str: out += chr(ord("a") + (ord(c) - ord("a") + n) % 26) else: out += c - return out + return ''.join(out) def main() -> None: s0 = input("Enter message: ") - s1 = dencrypt(s0, 13) + s1 = dencrypt(s0) print("Encryption:", s1) - s2 = dencrypt(s1, 13) + s2 = dencrypt(s1) print("Decryption: ", s2) From 3f5803d498005739ab743442cf5e50e5ee913d7a Mon Sep 17 00:00:00 2001 From: MadhavGupta1506 Date: Sat, 9 Nov 2024 16:48:13 +0530 Subject: [PATCH 2/4] fix-Used-list-instead-of-string-in-rot13.py-and-removed-n --- ciphers/rot13.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ciphers/rot13.py b/ciphers/rot13.py index b367c3215127..b1c7b875bb77 100644 --- a/ciphers/rot13.py +++ b/ciphers/rot13.py @@ -1,4 +1,4 @@ -def dencrypt(s: str, n: int = 13) -> str: +def dencrypt(s: str) -> str: """ https://en.wikipedia.org/wiki/ROT13 @@ -9,7 +9,7 @@ def dencrypt(s: str, n: int = 13) -> str: >>> dencrypt(s) == msg True """ - out = "" + out:list[str] = [] for c in s: if "A" <= c <= "Z": out += chr(ord("A") + (ord(c) - ord("A") + n) % 26) @@ -17,16 +17,16 @@ def dencrypt(s: str, n: int = 13) -> str: out += chr(ord("a") + (ord(c) - ord("a") + n) % 26) else: out += c - return out + return "".join(out) def main() -> None: s0 = input("Enter message: ") - s1 = dencrypt(s0, 13) + s1 = dencrypt(s0) print("Encryption:", s1) - s2 = dencrypt(s1, 13) + s2 = dencrypt(s1) print("Decryption: ", s2) From 85ad2e88ae5e32c39304aed7e520aa0d32cae5d7 Mon Sep 17 00:00:00 2001 From: MadhavGupta1506 Date: Sat, 9 Nov 2024 17:08:42 +0530 Subject: [PATCH 3/4] fix-Used-list-instead-of-string-in-rot13.py-and-removed-n --- data_structures/arrays/sudoku_solver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_structures/arrays/sudoku_solver.py b/data_structures/arrays/sudoku_solver.py index a8157a520c97..70bcdc748195 100644 --- a/data_structures/arrays/sudoku_solver.py +++ b/data_structures/arrays/sudoku_solver.py @@ -172,7 +172,7 @@ def unitsolved(unit): def from_file(filename, sep="\n"): "Parse a file into a list of strings, separated by sep." - return open(filename).read().strip().split(sep) # noqa: SIM115 + return open(filename).read().strip().split(sep) def random_puzzle(assignments=17): From 73126ad2106ce678306c829fb30673c2f84c477d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 9 Nov 2024 11:44:02 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ciphers/rot13.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ciphers/rot13.py b/ciphers/rot13.py index 2247ca1bfae2..cc43dcf7be06 100644 --- a/ciphers/rot13.py +++ b/ciphers/rot13.py @@ -9,8 +9,8 @@ def dencrypt(s: str) -> str: >>> dencrypt(s) == msg True """ - n=13 - out:list[str] = [] + n = 13 + out: list[str] = [] for c in s: if "A" <= c <= "Z": out += chr(ord("A") + (ord(c) - ord("A") + n) % 26) @@ -21,7 +21,6 @@ def dencrypt(s: str) -> str: return "".join(out) - def main() -> None: s0 = input("Enter message: ")