mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
Improve code on f-strings and brevity (#6126)
* Update strassen_matrix_multiplication.py * Update matrix_operation.py * Update enigma_machine2.py * Update enigma_machine.py * Update enigma_machine2.py * Update rod_cutting.py * Update external_sort.py * Update sol1.py * Update hill_cipher.py * Update prime_numbers.py * Update integration_by_simpson_approx.py
This commit is contained in:
@ -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
|
||||
|
@ -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:
|
||||
"""
|
||||
|
Reference in New Issue
Block a user