From 9590eb845ad5064b20937cd8b01f88a80a8a51b4 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 20 Oct 2022 15:39:55 +0200 Subject: [PATCH 1/7] My favorite palindrome --- strings/is_palindrome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/is_palindrome.py b/strings/is_palindrome.py index 4776a5fc29c4..1d143b1d64c7 100644 --- a/strings/is_palindrome.py +++ b/strings/is_palindrome.py @@ -3,7 +3,7 @@ def is_palindrome(s: str) -> bool: Determine whether the string is palindrome :param s: :return: Boolean - >>> is_palindrome("a man a plan a canal panama".replace(" ", "")) + >>> is_palindrome("A man, A plan, A canal -- Panama!") True >>> is_palindrome("Hello") False From e744f70355f87c7677c6bb8795744b69fb157db6 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Thu, 20 Oct 2022 13:40:40 +0000 Subject: [PATCH 2/7] updating DIRECTORY.md --- DIRECTORY.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 1fad287988c4..350764ec0042 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -360,6 +360,7 @@ * [Dijkstra](graphs/dijkstra.py) * [Dijkstra 2](graphs/dijkstra_2.py) * [Dijkstra Algorithm](graphs/dijkstra_algorithm.py) + * [Dijkstra Alternate](graphs/dijkstra_alternate.py) * [Dinic](graphs/dinic.py) * [Directed And Undirected (Weighted) Graph](graphs/directed_and_undirected_(weighted)_graph.py) * [Edmonds Karp Multiple Source And Sink](graphs/edmonds_karp_multiple_source_and_sink.py) @@ -936,6 +937,7 @@ * [Not Gate](quantum/not_gate.py) * [Q Full Adder](quantum/q_full_adder.py) * [Quantum Entanglement](quantum/quantum_entanglement.py) + * [Quantum Random](quantum/quantum_random.py) * [Ripple Adder Classic](quantum/ripple_adder_classic.py) * [Single Qubit Measure](quantum/single_qubit_measure.py) From a1c9be312c545ed2f754f736d5d14b3b9b90c67f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 20 Oct 2022 15:56:30 +0200 Subject: [PATCH 3/7] Update is_palindrome.py --- strings/is_palindrome.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/strings/is_palindrome.py b/strings/is_palindrome.py index 1d143b1d64c7..5cf5894a3993 100644 --- a/strings/is_palindrome.py +++ b/strings/is_palindrome.py @@ -1,8 +1,7 @@ def is_palindrome(s: str) -> bool: """ - Determine whether the string is palindrome - :param s: - :return: Boolean + Determine whether the string s is palindrome. + >>> is_palindrome("A man, A plan, A canal -- Panama!") True >>> is_palindrome("Hello") @@ -14,15 +13,15 @@ def is_palindrome(s: str) -> bool: >>> is_palindrome("Mr. Owl ate my metal worm?") True """ - # Since Punctuation, capitalization, and spaces are usually ignored while checking - # Palindrome, we first remove them from our string. - s = "".join([character for character in s.lower() if character.isalnum()]) + # Since punctuation, capitalization, and spaces are often ignored while checking + # palindromes, we first remove them from our string. + s = "".join(character for character in s.lower() if character.isalnum()) return s == s[::-1] if __name__ == "__main__": - s = input("Enter string to determine whether its palindrome or not: ").strip() + s = input("Please enter string to see if it is a palindrome: ") if is_palindrome(s): - print("Given string is palindrome") + print(f"'{s}' is a palindrome.") else: - print("Given string is not palindrome") + print(f"'{s}' is not a palindrome.") From 2a5f27ae377df88b7e2b2b2f7c67415be82d6454 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 20 Oct 2022 15:57:01 +0200 Subject: [PATCH 4/7] Update is_palindrome.py --- strings/is_palindrome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/is_palindrome.py b/strings/is_palindrome.py index 5cf5894a3993..255b708d20a1 100644 --- a/strings/is_palindrome.py +++ b/strings/is_palindrome.py @@ -1,6 +1,6 @@ def is_palindrome(s: str) -> bool: """ - Determine whether the string s is palindrome. + Determine if the string s is palindrome. >>> is_palindrome("A man, A plan, A canal -- Panama!") True From 35ad485e2e113cc262f6ab3e082283d2304bb48f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 20 Oct 2022 14:00:59 +0000 Subject: [PATCH 5/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- strings/is_palindrome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/is_palindrome.py b/strings/is_palindrome.py index 255b708d20a1..358116c52c89 100644 --- a/strings/is_palindrome.py +++ b/strings/is_palindrome.py @@ -1,7 +1,7 @@ def is_palindrome(s: str) -> bool: """ Determine if the string s is palindrome. - + >>> is_palindrome("A man, A plan, A canal -- Panama!") True >>> is_palindrome("Hello") From 171501da62751ddd5e5b0643d020d2c9b24a0164 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 20 Oct 2022 19:50:10 +0200 Subject: [PATCH 6/7] Update strings/is_palindrome.py Co-authored-by: Caeden Perelli-Harris --- strings/is_palindrome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/is_palindrome.py b/strings/is_palindrome.py index 358116c52c89..7310f04952f3 100644 --- a/strings/is_palindrome.py +++ b/strings/is_palindrome.py @@ -20,7 +20,7 @@ def is_palindrome(s: str) -> bool: if __name__ == "__main__": - s = input("Please enter string to see if it is a palindrome: ") + s = input("Please enter a string to see if it is a palindrome: ") if is_palindrome(s): print(f"'{s}' is a palindrome.") else: From 33b31f40553034cf91100886d37633e25aff2bed Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 20 Oct 2022 20:10:15 +0200 Subject: [PATCH 7/7] Update is_palindrome.py --- strings/is_palindrome.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/strings/is_palindrome.py b/strings/is_palindrome.py index 7310f04952f3..5758af0cef9b 100644 --- a/strings/is_palindrome.py +++ b/strings/is_palindrome.py @@ -1,6 +1,6 @@ def is_palindrome(s: str) -> bool: """ - Determine if the string s is palindrome. + Determine if the string s is a palindrome. >>> is_palindrome("A man, A plan, A canal -- Panama!") True @@ -14,7 +14,7 @@ def is_palindrome(s: str) -> bool: True """ # Since punctuation, capitalization, and spaces are often ignored while checking - # palindromes, we first remove them from our string. + # palindromes, we first remove them from our string. s = "".join(character for character in s.lower() if character.isalnum()) return s == s[::-1]