From d62ebf7274ae69e689bcec73ac0400e7f827f4ba Mon Sep 17 00:00:00 2001 From: Vivek Date: Sat, 20 Jun 2026 11:33:40 +0530 Subject: [PATCH 1/6] corrected the typos --- strings/camel_case_to_snake_case.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/strings/camel_case_to_snake_case.py b/strings/camel_case_to_snake_case.py index 582907be2edb..a01b8e4c06bb 100644 --- a/strings/camel_case_to_snake_case.py +++ b/strings/camel_case_to_snake_case.py @@ -5,8 +5,8 @@ def camel_to_snake_case(input_str: str) -> str: >>> camel_to_snake_case("someRandomString") 'some_random_string' - >>> camel_to_snake_case("SomeRandomStr#ng") - 'some_random_str_ng' + >>> camel_to_snake_case("SomeRandomString") + 'some_random_string' >>> camel_to_snake_case("123someRandom123String123") '123_some_random_123_string_123' From 08452b57199cc829e8fa8f8b9c93dc018685e7cf Mon Sep 17 00:00:00 2001 From: Vivek Date: Sun, 21 Jun 2026 20:54:55 +0530 Subject: [PATCH 2/6] added new file --- strings/secret_language.py | 86 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 strings/secret_language.py diff --git a/strings/secret_language.py b/strings/secret_language.py new file mode 100644 index 000000000000..78fc48380200 --- /dev/null +++ b/strings/secret_language.py @@ -0,0 +1,86 @@ +# Encoding & Decoding + +import random +import string + + +def random_chars() -> str: + """ + Generate a random string of 3 ASCII letters. + + >>> import random + >>> random.seed(42) + >>> random_chars() + 'ZoX' + """ + return ''.join(random.choices(string.ascii_letters, k=3)) + + +def random_digits() -> str: + """ + Generate a random string of 3 digits. + + >>> import random + >>> random.seed(42) + >>> random_digits() + '638' + """ + return ''.join(random.choices(string.digits, k=3)) + + +def encode(code: str) -> str: + """ + Encode a string by shifting the first character to the end and + wrapping it with random padding of 3 letters and 3 digits on each side. + + Reference: https://en.wikipedia.org/wiki/Caesar_cipher + + >>> import random + >>> random.seed(42) + >>> encode('hello') + 'ZoX638elloh415mJu' + + >>> import random + >>> random.seed(42) + >>> encode('hi') + 'ZoX638ih415mJu' + """ + if len(code) >= 3: + code = code[1:] + code[0] + code = random_chars() + random_digits() + code + random_digits() + random_chars() + else: + code = code[::-1] + code = random_chars() + random_digits() + code + random_digits() + random_chars() + return code + + +def decode(code: str) -> str: + """ + Decode an encoded string by stripping the random padding and + reversing the character shift. + + >>> import random + >>> random.seed(42) + >>> decode(encode('hello')) + 'hello' + + >>> import random + >>> random.seed(42) + >>> decode(encode('hi')) + 'hi' + """ + code = code[6:-6] + if len(code) >= 3: + code = code[-1] + code[:-1] + else: + code = code[::-1] + return code + + +if __name__ == "__main__": + code = input("Enter the code: ") + encoded = encode(code) + decoded = decode(encoded) + print(f"Original → {code}") + print(f"Encoded → {encoded}") + print(f"Decoded → {decoded}")v \ No newline at end of file From 65418694c116286c55e18d2fac3324ce449e1d1f Mon Sep 17 00:00:00 2001 From: Vivek Date: Sun, 21 Jun 2026 20:55:35 +0530 Subject: [PATCH 3/6] added new secre_language file --- strings/secret_language.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/secret_language.py b/strings/secret_language.py index 78fc48380200..33f457656b7e 100644 --- a/strings/secret_language.py +++ b/strings/secret_language.py @@ -83,4 +83,4 @@ def decode(code: str) -> str: decoded = decode(encoded) print(f"Original → {code}") print(f"Encoded → {encoded}") - print(f"Decoded → {decoded}")v \ No newline at end of file + print(f"Decoded → {decoded}") \ No newline at end of file From 01ce7eb2bf59bdb33e16dd4ffd8ba670d2d9ec47 Mon Sep 17 00:00:00 2001 From: Vivek Date: Sun, 21 Jun 2026 21:06:29 +0530 Subject: [PATCH 4/6] modified the file --- strings/secret_language.py | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/strings/secret_language.py b/strings/secret_language.py index 33f457656b7e..11e77ab74036 100644 --- a/strings/secret_language.py +++ b/strings/secret_language.py @@ -9,9 +9,10 @@ def random_chars() -> str: Generate a random string of 3 ASCII letters. >>> import random - >>> random.seed(42) - >>> random_chars() - 'ZoX' + >>> len(random_chars()) == 3 + True + >>> all(c in string.ascii_letters for c in random_chars()) + True """ return ''.join(random.choices(string.ascii_letters, k=3)) @@ -20,10 +21,10 @@ def random_digits() -> str: """ Generate a random string of 3 digits. - >>> import random - >>> random.seed(42) - >>> random_digits() - '638' + >>> len(random_digits()) == 3 + True + >>> all(c in string.digits for c in random_digits()) + True """ return ''.join(random.choices(string.digits, k=3)) @@ -35,15 +36,10 @@ def encode(code: str) -> str: Reference: https://en.wikipedia.org/wiki/Caesar_cipher - >>> import random - >>> random.seed(42) - >>> encode('hello') - 'ZoX638elloh415mJu' - - >>> import random - >>> random.seed(42) - >>> encode('hi') - 'ZoX638ih415mJu' + >>> len(encode('hello')) == len('hello') + 12 + True + >>> len(encode('hi')) == len('hi') + 12 + True """ if len(code) >= 3: code = code[1:] + code[0] @@ -59,15 +55,12 @@ def decode(code: str) -> str: Decode an encoded string by stripping the random padding and reversing the character shift. - >>> import random - >>> random.seed(42) >>> decode(encode('hello')) 'hello' - - >>> import random - >>> random.seed(42) >>> decode(encode('hi')) 'hi' + >>> decode(encode('python')) + 'python' """ code = code[6:-6] if len(code) >= 3: From 9cc1d1236fb747d409434b91cf46a1e028dbcc51 Mon Sep 17 00:00:00 2001 From: Vivek Date: Sun, 21 Jun 2026 21:07:55 +0530 Subject: [PATCH 5/6] added secret_language file --- strings/secret_language.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/strings/secret_language.py b/strings/secret_language.py index 11e77ab74036..8777b66a347d 100644 --- a/strings/secret_language.py +++ b/strings/secret_language.py @@ -5,15 +5,20 @@ def random_chars() -> str: - """ + ''' Generate a random string of 3 ASCII letters. >>> import random >>> len(random_chars()) == 3 True + + >>> all(c in string.ascii_letters for c in random_chars()) True - """ + + + + ''' return ''.join(random.choices(string.ascii_letters, k=3)) @@ -23,6 +28,9 @@ def random_digits() -> str: >>> len(random_digits()) == 3 True + + + >>> all(c in string.digits for c in random_digits()) True """ @@ -40,6 +48,8 @@ def encode(code: str) -> str: True >>> len(encode('hi')) == len('hi') + 12 True + + """ if len(code) >= 3: code = code[1:] + code[0] @@ -61,6 +71,9 @@ def decode(code: str) -> str: 'hi' >>> decode(encode('python')) 'python' + + + """ code = code[6:-6] if len(code) >= 3: From d7abc8da170a0e2d1aeb939c7f792554d9022867 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 21 Jun 2026 15:44:51 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- strings/secret_language.py | 44 +++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/strings/secret_language.py b/strings/secret_language.py index 8777b66a347d..db401a2d0460 100644 --- a/strings/secret_language.py +++ b/strings/secret_language.py @@ -5,21 +5,21 @@ def random_chars() -> str: - ''' + """ Generate a random string of 3 ASCII letters. >>> import random >>> len(random_chars()) == 3 True - - + + >>> all(c in string.ascii_letters for c in random_chars()) True - - - - ''' - return ''.join(random.choices(string.ascii_letters, k=3)) + + + + """ + return "".join(random.choices(string.ascii_letters, k=3)) def random_digits() -> str: @@ -28,13 +28,13 @@ def random_digits() -> str: >>> len(random_digits()) == 3 True - - - + + + >>> all(c in string.digits for c in random_digits()) True """ - return ''.join(random.choices(string.digits, k=3)) + return "".join(random.choices(string.digits, k=3)) def encode(code: str) -> str: @@ -48,15 +48,19 @@ def encode(code: str) -> str: True >>> len(encode('hi')) == len('hi') + 12 True - - + + """ if len(code) >= 3: code = code[1:] + code[0] - code = random_chars() + random_digits() + code + random_digits() + random_chars() + code = ( + random_chars() + random_digits() + code + random_digits() + random_chars() + ) else: code = code[::-1] - code = random_chars() + random_digits() + code + random_digits() + random_chars() + code = ( + random_chars() + random_digits() + code + random_digits() + random_chars() + ) return code @@ -71,9 +75,9 @@ def decode(code: str) -> str: 'hi' >>> decode(encode('python')) 'python' - - - + + + """ code = code[6:-6] if len(code) >= 3: @@ -89,4 +93,4 @@ def decode(code: str) -> str: decoded = decode(encoded) print(f"Original → {code}") print(f"Encoded → {encoded}") - print(f"Decoded → {decoded}") \ No newline at end of file + print(f"Decoded → {decoded}")