From a74bd1a95ec3c0ff21e1f90603fee543269f0346 Mon Sep 17 00:00:00 2001 From: Arzoo1701 Date: Fri, 24 Oct 2025 04:06:39 +0530 Subject: [PATCH 01/13] feat: Add palindrome check to basic logic problems (Closes #13501) --- other/palindrome_check.py | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 other/palindrome_check.py diff --git a/other/palindrome_check.py b/other/palindrome_check.py new file mode 100644 index 000000000000..ec91b944526d --- /dev/null +++ b/other/palindrome_check.py @@ -0,0 +1,40 @@ +from typing import Text # Imports the 'Text' type for clarity (optional, but good practice) + +def is_palindrome(text: Text) -> bool: + """ + Checks if a string is a palindrome. + + A palindrome is a word, phrase, number, or other sequence of characters + which reads the same backward as forward. This implementation is case-sensitive + and includes spaces and punctuation in the check. + + Args: + text: The input string to check. + + Returns: + True if the string is a palindrome, False otherwise. + + Examples (Doctests): + >>> is_palindrome("madam") + True + >>> is_palindrome("racecar") + True + >>> is_palindrome("A man, a plan, a canal: Panama") + False + >>> is_palindrome("level") + True + >>> is_palindrome("hello") + False + """ + # Core logic: The simplest and most Pythonic way to reverse a string + # is using slicing: text[::-1]. + # We compare the original string with its reversed version. + return text == text[::-1] + + +if __name__ == "__main__": + # Standard boilerplate for running documentation examples as tests. + # When this file is run directly (python file.py), it executes the + # doctest examples inside the docstring to verify the function works. + import doctest + doctest.testmod() \ No newline at end of file From 025f1db2bf4bdcf6885c07b179001acd89190ff4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Oct 2025 22:50:04 +0000 Subject: [PATCH 02/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- other/palindrome_check.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/other/palindrome_check.py b/other/palindrome_check.py index ec91b944526d..f5d7ed64fc44 100644 --- a/other/palindrome_check.py +++ b/other/palindrome_check.py @@ -1,4 +1,7 @@ -from typing import Text # Imports the 'Text' type for clarity (optional, but good practice) +from typing import ( + Text, +) # Imports the 'Text' type for clarity (optional, but good practice) + def is_palindrome(text: Text) -> bool: """ @@ -37,4 +40,5 @@ def is_palindrome(text: Text) -> bool: # When this file is run directly (python file.py), it executes the # doctest examples inside the docstring to verify the function works. import doctest - doctest.testmod() \ No newline at end of file + + doctest.testmod() From 10dae9e284a82942ec4aa6d826309ea9e4321e4d Mon Sep 17 00:00:00 2001 From: Arzoo1701 Date: Fri, 24 Oct 2025 04:28:04 +0530 Subject: [PATCH 03/13] fix: resolve Ruff and linting errors for palindrome_check.py --- other/palindrome_check.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/other/palindrome_check.py b/other/palindrome_check.py index ec91b944526d..8fd4cb6d3b53 100644 --- a/other/palindrome_check.py +++ b/other/palindrome_check.py @@ -1,6 +1,7 @@ -from typing import Text # Imports the 'Text' type for clarity (optional, but good practice) +# Fixed: I001 (Import sorted), E501 (Line length), UP019 (Use 'str') +from typing import Text -def is_palindrome(text: Text) -> bool: +def is_palindrome(text: str) -> bool: """ Checks if a string is a palindrome. @@ -34,7 +35,5 @@ def is_palindrome(text: Text) -> bool: if __name__ == "__main__": # Standard boilerplate for running documentation examples as tests. - # When this file is run directly (python file.py), it executes the - # doctest examples inside the docstring to verify the function works. import doctest - doctest.testmod() \ No newline at end of file + doctest.testmod() # Fixed: W292 (Newline added after this line) \ No newline at end of file From ccd5989b34c07f300259476cb0f77a8d7c8c9b83 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Oct 2025 23:23:47 +0000 Subject: [PATCH 04/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- other/palindrome_check.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/other/palindrome_check.py b/other/palindrome_check.py index a51210242620..ca4cfaf62499 100644 --- a/other/palindrome_check.py +++ b/other/palindrome_check.py @@ -33,5 +33,6 @@ def is_palindrome(text: str) -> bool: if __name__ == "__main__": # Standard boilerplate for running documentation examples as tests. import doctest + doctest.testmod() - # Ensure there is ONE blank newline at the end of this file (to fix W292) \ No newline at end of file + # Ensure there is ONE blank newline at the end of this file (to fix W292) From fb207b5543f25d5a27fb193afda16bd1aecffaca Mon Sep 17 00:00:00 2001 From: Arzoo1701 Date: Fri, 24 Oct 2025 05:02:41 +0530 Subject: [PATCH 05/13] fix: Resolve final W292 newline error --- other/palindrome_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/other/palindrome_check.py b/other/palindrome_check.py index a51210242620..ba4c11c05885 100644 --- a/other/palindrome_check.py +++ b/other/palindrome_check.py @@ -34,4 +34,4 @@ def is_palindrome(text: str) -> bool: # Standard boilerplate for running documentation examples as tests. import doctest doctest.testmod() - # Ensure there is ONE blank newline at the end of this file (to fix W292) \ No newline at end of file + From d1701fe80b903da7d7cf1fe3488782ddd6ff30bc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Oct 2025 23:41:48 +0000 Subject: [PATCH 06/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- other/palindrome_check.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/other/palindrome_check.py b/other/palindrome_check.py index 8bc61df9d4ae..7fc72214cb6d 100644 --- a/other/palindrome_check.py +++ b/other/palindrome_check.py @@ -33,7 +33,5 @@ def is_palindrome(text: str) -> bool: if __name__ == "__main__": # Standard boilerplate for running documentation examples as tests. import doctest - doctest.testmod() - - + doctest.testmod() From e8ad0b579ca5fe1991515fd2f15ecce0527ac232 Mon Sep 17 00:00:00 2001 From: Arzoo1701 Date: Fri, 24 Oct 2025 05:18:30 +0530 Subject: [PATCH 07/13] fix: Resolve final W293 whitespace error --- other/palindrome_check.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/other/palindrome_check.py b/other/palindrome_check.py index 8bc61df9d4ae..44b9e91ddde6 100644 --- a/other/palindrome_check.py +++ b/other/palindrome_check.py @@ -34,6 +34,4 @@ def is_palindrome(text: str) -> bool: # Standard boilerplate for running documentation examples as tests. import doctest doctest.testmod() - - - + \ No newline at end of file From 6ec0d2474044ddbea7d5f4766a8fe3591f743268 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Oct 2025 23:53:25 +0000 Subject: [PATCH 08/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- other/palindrome_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/other/palindrome_check.py b/other/palindrome_check.py index ba4c11c05885..7fc72214cb6d 100644 --- a/other/palindrome_check.py +++ b/other/palindrome_check.py @@ -33,5 +33,5 @@ def is_palindrome(text: str) -> bool: if __name__ == "__main__": # Standard boilerplate for running documentation examples as tests. import doctest + doctest.testmod() - From ec3a7e8b64064e2e93516e0c77f5324a41cc14f8 Mon Sep 17 00:00:00 2001 From: Arzoo1701 Date: Fri, 24 Oct 2025 05:26:20 +0530 Subject: [PATCH 09/13] fix: Resolve final W293 whitespace error --- other/palindrome_check.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/other/palindrome_check.py b/other/palindrome_check.py index ba4c11c05885..4d418e0265f3 100644 --- a/other/palindrome_check.py +++ b/other/palindrome_check.py @@ -33,5 +33,4 @@ def is_palindrome(text: str) -> bool: if __name__ == "__main__": # Standard boilerplate for running documentation examples as tests. import doctest - doctest.testmod() - + doctest.testmod() \ No newline at end of file From d85558d5e169c90696b0b9726cc72b6a4ce59ebb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Oct 2025 23:59:03 +0000 Subject: [PATCH 10/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- other/palindrome_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/other/palindrome_check.py b/other/palindrome_check.py index ba4c11c05885..7fc72214cb6d 100644 --- a/other/palindrome_check.py +++ b/other/palindrome_check.py @@ -33,5 +33,5 @@ def is_palindrome(text: str) -> bool: if __name__ == "__main__": # Standard boilerplate for running documentation examples as tests. import doctest + doctest.testmod() - From 4aff923721a8d7edebdeed1ea6d82774466b1c8a Mon Sep 17 00:00:00 2001 From: Arzoo1701 Date: Fri, 24 Oct 2025 05:37:42 +0530 Subject: [PATCH 11/13] fix: Final resolution for W293 whitespace --- other/palindrome_check.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/other/palindrome_check.py b/other/palindrome_check.py index ba4c11c05885..d29b303fdbd2 100644 --- a/other/palindrome_check.py +++ b/other/palindrome_check.py @@ -28,10 +28,7 @@ def is_palindrome(text: str) -> bool: # is using slicing: text[::-1]. # We compare the original string with its reversed version. return text == text[::-1] - - if __name__ == "__main__": # Standard boilerplate for running documentation examples as tests. import doctest - doctest.testmod() - + doctest.testmod() \ No newline at end of file From 5a7a617e7930f6d78d7e965971a87c4acf099201 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 24 Oct 2025 00:13:47 +0000 Subject: [PATCH 12/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- other/palindrome_check.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/other/palindrome_check.py b/other/palindrome_check.py index 12576a664032..7fc72214cb6d 100644 --- a/other/palindrome_check.py +++ b/other/palindrome_check.py @@ -28,8 +28,10 @@ def is_palindrome(text: str) -> bool: # is using slicing: text[::-1]. # We compare the original string with its reversed version. return text == text[::-1] + + if __name__ == "__main__": # Standard boilerplate for running documentation examples as tests. import doctest + doctest.testmod() - \ No newline at end of file From ce8ab1e06ea0354f4ef22e5a4f4601c7837f4633 Mon Sep 17 00:00:00 2001 From: Arzoo1701 Date: Fri, 24 Oct 2025 05:44:57 +0530 Subject: [PATCH 13/13] fix: Final resolution for W293 whitespace --- other/palindrome_check.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/other/palindrome_check.py b/other/palindrome_check.py index 12576a664032..7deda43221b0 100644 --- a/other/palindrome_check.py +++ b/other/palindrome_check.py @@ -28,6 +28,8 @@ def is_palindrome(text: str) -> bool: # is using slicing: text[::-1]. # We compare the original string with its reversed version. return text == text[::-1] + + if __name__ == "__main__": # Standard boilerplate for running documentation examples as tests. import doctest