Skip to content

Commit

Permalink
Fix typos in Sorts and Bit_manipulation (TheAlgorithms#4949)
Browse files Browse the repository at this point in the history
* Fix several typos

* Update bit_manipulation/README.md

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Update double_sort.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
  • Loading branch information
Manan-Rathi and poyea authored Oct 20, 2021
1 parent 83cf578 commit 50485f7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
13 changes: 6 additions & 7 deletions bit_manipulation/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +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
4 changes: 2 additions & 2 deletions bit_manipulation/binary_and_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
...
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions bit_manipulation/binary_or_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
...
Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions bit_manipulation/binary_xor_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
...
Expand All @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions sorts/bead_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions sorts/double_sort.py
Original file line number Diff line number Diff line change
@@ -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"
"""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, it's called "Double sort"
:param collection: mutable ordered sequence of elements
:return: the same collection in ascending order
Examples:
Expand Down

0 comments on commit 50485f7

Please sign in to comment.