From ddc1d5f8ff6c63500c9cb49ed359d70e722257df Mon Sep 17 00:00:00 2001 From: Manan-Rathi Date: Sun, 3 Oct 2021 13:47:34 +0530 Subject: [PATCH 1/3] Fix several typos --- bit_manipulation/README.md | 4 ++++ bit_manipulation/binary_and_operator.py | 4 ++-- bit_manipulation/binary_or_operator.py | 4 ++-- bit_manipulation/binary_xor_operator.py | 4 ++-- sorts/bead_sort.py | 8 ++++---- sorts/double_sort.py | 4 ++-- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/bit_manipulation/README.md b/bit_manipulation/README.md index 2ef1661524f2..0527fc30da25 100644 --- a/bit_manipulation/README.md +++ b/bit_manipulation/README.md @@ -1,7 +1,11 @@ https://docs.python.org/3/reference/expressions.html#binary-bitwise-operations + https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations + https://docs.python.org/3/library/stdtypes.html#bitwise-operations-on-integer-types https://wiki.python.org/moin/BitManipulation + https://wiki.python.org/moin/BitwiseOperators + https://www.tutorialspoint.com/python3/bitwise_operators_example.htm diff --git a/bit_manipulation/binary_and_operator.py b/bit_manipulation/binary_and_operator.py index 191ff8eb44a4..36f6c668d9b3 100644 --- a/bit_manipulation/binary_and_operator.py +++ b/bit_manipulation/binary_and_operator.py @@ -22,7 +22,7 @@ def binary_and(a: int, b: int) -> str: >>> binary_and(0, -1) Traceback (most recent call last): ... - ValueError: the value of both input must be positive + ValueError: the value of both inputs must be positive >>> binary_and(0, 1.1) Traceback (most recent call last): ... @@ -33,7 +33,7 @@ def binary_and(a: int, b: int) -> str: TypeError: '<' not supported between instances of 'str' and 'int' """ if a < 0 or b < 0: - raise ValueError("the value of both input must be positive") + raise ValueError("the value of both inputs must be positive") a_binary = str(bin(a))[2:] # remove the leading "0b" b_binary = str(bin(b))[2:] # remove the leading "0b" diff --git a/bit_manipulation/binary_or_operator.py b/bit_manipulation/binary_or_operator.py index dabf5bcb09fd..95f61f1da64e 100644 --- a/bit_manipulation/binary_or_operator.py +++ b/bit_manipulation/binary_or_operator.py @@ -21,7 +21,7 @@ def binary_or(a: int, b: int) -> str: >>> binary_or(0, -1) Traceback (most recent call last): ... - ValueError: the value of both input must be positive + ValueError: the value of both inputs must be positive >>> binary_or(0, 1.1) Traceback (most recent call last): ... @@ -32,7 +32,7 @@ def binary_or(a: int, b: int) -> str: TypeError: '<' not supported between instances of 'str' and 'int' """ if a < 0 or b < 0: - raise ValueError("the value of both input must be positive") + raise ValueError("the value of both inputs must be positive") a_binary = str(bin(a))[2:] # remove the leading "0b" b_binary = str(bin(b))[2:] max_len = max(len(a_binary), len(b_binary)) diff --git a/bit_manipulation/binary_xor_operator.py b/bit_manipulation/binary_xor_operator.py index 6f8962192ad8..6206c70a99f6 100644 --- a/bit_manipulation/binary_xor_operator.py +++ b/bit_manipulation/binary_xor_operator.py @@ -22,7 +22,7 @@ def binary_xor(a: int, b: int) -> str: >>> binary_xor(0, -1) Traceback (most recent call last): ... - ValueError: the value of both input must be positive + ValueError: the value of both inputs must be positive >>> binary_xor(0, 1.1) Traceback (most recent call last): ... @@ -33,7 +33,7 @@ def binary_xor(a: int, b: int) -> str: TypeError: '<' not supported between instances of 'str' and 'int' """ if a < 0 or b < 0: - raise ValueError("the value of both input must be positive") + raise ValueError("the value of both inputs must be positive") a_binary = str(bin(a))[2:] # remove the leading "0b" b_binary = str(bin(b))[2:] # remove the leading "0b" diff --git a/sorts/bead_sort.py b/sorts/bead_sort.py index 3767e842d8c2..d22367c52fa9 100644 --- a/sorts/bead_sort.py +++ b/sorts/bead_sort.py @@ -1,5 +1,5 @@ """ -Bead sort only works for sequences of nonegative integers. +Bead sort only works for sequences of non-negative integers. https://en.wikipedia.org/wiki/Bead_sort """ @@ -21,15 +21,15 @@ def bead_sort(sequence: list) -> list: >>> bead_sort([1, .9, 0.0, 0, -1, -.9]) Traceback (most recent call last): ... - TypeError: Sequence must be list of nonnegative integers + TypeError: Sequence must be list of non-negative integers >>> bead_sort("Hello world") Traceback (most recent call last): ... - TypeError: Sequence must be list of nonnegative integers + TypeError: Sequence must be list of non-negative integers """ if any(not isinstance(x, int) or x < 0 for x in sequence): - raise TypeError("Sequence must be list of nonnegative integers") + raise TypeError("Sequence must be list of non-negative integers") for _ in range(len(sequence)): for i, (rod_upper, rod_lower) in enumerate(zip(sequence, sequence[1:])): if rod_upper > rod_lower: diff --git a/sorts/double_sort.py b/sorts/double_sort.py index 04e18682017c..56eaaeef2712 100644 --- a/sorts/double_sort.py +++ b/sorts/double_sort.py @@ -1,7 +1,7 @@ def double_sort(lst): - """this sorting algorithm sorts an array using the principle of bubble sort, + """This sorting algorithm sorts an array using the principle of bubble sort, but does it both from left to right and right to left, - hence i decided to call it "double sort" + hence I decided to call it "Double sort" :param collection: mutable ordered sequence of elements :return: the same collection in ascending order Examples: From d3f28ee37cb31e03d26fc79d704691701fe8ab49 Mon Sep 17 00:00:00 2001 From: Manan-Rathi <76519771+Manan-Rathi@users.noreply.github.com> Date: Wed, 6 Oct 2021 21:40:00 +0530 Subject: [PATCH 2/3] Update bit_manipulation/README.md Co-authored-by: John Law --- bit_manipulation/README.md | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/bit_manipulation/README.md b/bit_manipulation/README.md index 0527fc30da25..e5f82a270e28 100644 --- a/bit_manipulation/README.md +++ b/bit_manipulation/README.md @@ -1,11 +1,6 @@ -https://docs.python.org/3/reference/expressions.html#binary-bitwise-operations - -https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations - -https://docs.python.org/3/library/stdtypes.html#bitwise-operations-on-integer-types - -https://wiki.python.org/moin/BitManipulation - -https://wiki.python.org/moin/BitwiseOperators - -https://www.tutorialspoint.com/python3/bitwise_operators_example.htm +* https://docs.python.org/3/reference/expressions.html#binary-bitwise-operations +* https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations +* https://docs.python.org/3/library/stdtypes.html#bitwise-operations-on-integer-types +* https://wiki.python.org/moin/BitManipulation +* https://wiki.python.org/moin/BitwiseOperators +* https://www.tutorialspoint.com/python3/bitwise_operators_example.htm From e7abeecf56f1a0fa71edb6d3699be5e49ad79bc1 Mon Sep 17 00:00:00 2001 From: Manan-Rathi <76519771+Manan-Rathi@users.noreply.github.com> Date: Wed, 6 Oct 2021 21:46:01 +0530 Subject: [PATCH 3/3] Update double_sort.py --- sorts/double_sort.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sorts/double_sort.py b/sorts/double_sort.py index 56eaaeef2712..4e08e27b3c21 100644 --- a/sorts/double_sort.py +++ b/sorts/double_sort.py @@ -1,7 +1,7 @@ def double_sort(lst): """This sorting algorithm sorts an array using the principle of bubble sort, - but does it both from left to right and right to left, - hence I decided to call it "Double sort" + but does it both from left to right and right to left. + Hence, it's called "Double sort" :param collection: mutable ordered sequence of elements :return: the same collection in ascending order Examples: