Skip to content
6 changes: 3 additions & 3 deletions ciphers/enigma_machine2.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ def _validator(
rotorpos1, rotorpos2, rotorpos3 = rotpos
if not 0 < rotorpos1 <= len(abc):
raise ValueError(
f"First rotor position is not within range of 1..26 (" f"{rotorpos1}"
"First rotor position is not within range of 1..26 (" f"{rotorpos1}"
)
if not 0 < rotorpos2 <= len(abc):
raise ValueError(
f"Second rotor position is not within range of 1..26 (" f"{rotorpos2})"
"Second rotor position is not within range of 1..26 (" f"{rotorpos2})"
)
if not 0 < rotorpos3 <= len(abc):
raise ValueError(
f"Third rotor position is not within range of 1..26 (" f"{rotorpos3})"
"Third rotor position is not within range of 1..26 (" f"{rotorpos3})"
)

# Validates string and returns dict
Expand Down
2 changes: 1 addition & 1 deletion ciphers/hill_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class HillCipher:
# take x and return x % len(key_string)
modulus = numpy.vectorize(lambda x: x % 36)

to_int = numpy.vectorize(lambda x: round(x))
to_int = numpy.vectorize(round)

def __init__(self, encrypt_key: numpy.ndarray) -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion data_structures/hashing/number_theory/prime_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def check_prime(number):
elif number == special_non_primes[-1]:
return 3

return all([number % i for i in range(2, number)])
return all(number % i for i in range(2, number))


def next_prime(value, factor=1, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion divide_and_conquer/strassen_matrix_multiplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def strassen(matrix1: list, matrix2: list) -> list:
"""
if matrix_dimensions(matrix1)[1] != matrix_dimensions(matrix2)[0]:
raise Exception(
f"Unable to multiply these matrices, please check the dimensions. \n"
"Unable to multiply these matrices, please check the dimensions. \n"
f"Matrix A:{matrix1} \nMatrix B:{matrix2}"
)
dimension1 = matrix_dimensions(matrix1)
Expand Down
2 changes: 1 addition & 1 deletion dynamic_programming/rod_cutting.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _enforce_args(n: int, prices: list):

if n > len(prices):
raise ValueError(
f"Each integral piece of rod must have a corresponding "
"Each integral piece of rod must have a corresponding "
f"price. Got n = {n} but length of prices = {len(prices)}"
)

Expand Down
2 changes: 1 addition & 1 deletion hashes/enigma_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ def engine(input_character):
print("\n" + "".join(code))
print(
f"\nYour Token is {token} please write it down.\nIf you want to decode "
f"this message again you should input same digits as token!"
"this message again you should input same digits as token!"
)
10 changes: 3 additions & 7 deletions maths/integration_by_simpson_approx.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,12 @@ def simpson_integration(function, a: float, b: float, precision: int = 4) -> flo
assert callable(
function
), f"the function(object) passed should be callable your input : {function}"
assert isinstance(a, float) or isinstance(
a, int
), f"a should be float or integer your input : {a}"
assert isinstance(function(a), float) or isinstance(function(a), int), (
assert isinstance(a, (float, int)), f"a should be float or integer your input : {a}"
assert isinstance(function(a), (float, int)), (
"the function should return integer or float return type of your function, "
f"{type(a)}"
)
assert isinstance(b, float) or isinstance(
b, int
), f"b should be float or integer your input : {b}"
assert isinstance(b, (float, int)), f"b should be float or integer your input : {b}"
assert (
isinstance(precision, int) and precision > 0
), f"precision should be positive integer your input : {precision}"
Expand Down
2 changes: 1 addition & 1 deletion matrix/matrix_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _verify_matrix_sizes(
shape = _shape(matrix_a) + _shape(matrix_b)
if shape[0] != shape[3] or shape[1] != shape[2]:
raise ValueError(
f"operands could not be broadcast together with shape "
"operands could not be broadcast together with shape "
f"({shape[0], shape[1]}), ({shape[2], shape[3]})"
)
return (shape[0], shape[2]), (shape[1], shape[3])
Expand Down
2 changes: 1 addition & 1 deletion project_euler/problem_067/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def solution():
triangle = f.readlines()

a = map(lambda x: x.rstrip("\r\n").split(" "), triangle)
a = list(map(lambda x: list(map(lambda y: int(y), x)), a))
a = list(map(lambda x: list(map(int, x)), a))

for i in range(1, len(a)):
for j in range(len(a[i])):
Expand Down
2 changes: 1 addition & 1 deletion sorts/external_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def split(self, block_size, sort_key=None):
i += 1

def cleanup(self):
map(lambda f: os.remove(f), self.block_filenames)
map(os.remove, self.block_filenames)


class NWayMerge:
Expand Down