Add pep8-naming to pre-commit hooks and fixes incorrect naming conventions (#7062)

* ci(pre-commit): Add pep8-naming to `pre-commit` hooks (#7038)

* refactor: Fix naming conventions (#7038)

* Update arithmetic_analysis/lu_decomposition.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* refactor(lu_decomposition): Replace `NDArray` with `ArrayLike` (#7038)

* chore: Fix naming conventions in doctests (#7038)

* fix: Temporarily disable project euler problem 104 (#7069)

* chore: Fix naming conventions in doctests (#7038)

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Caeden
2022-10-12 23:54:20 +01:00
committed by GitHub
parent e2cd982b11
commit 07e991d553
140 changed files with 1552 additions and 1536 deletions

View File

@ -14,53 +14,53 @@ def main() -> None:
mode = input("Encryption/Decryption [e/d]: ")
if mode.lower().startswith("e"):
text = encryptMessage(key, message)
text = encrypt_message(key, message)
elif mode.lower().startswith("d"):
text = decryptMessage(key, message)
text = decrypt_message(key, message)
# Append pipe symbol (vertical bar) to identify spaces at the end.
print(f"Output:\n{text + '|'}")
def encryptMessage(key: int, message: str) -> str:
def encrypt_message(key: int, message: str) -> str:
"""
>>> encryptMessage(6, 'Harshil Darji')
>>> encrypt_message(6, 'Harshil Darji')
'Hlia rDsahrij'
"""
cipherText = [""] * key
cipher_text = [""] * key
for col in range(key):
pointer = col
while pointer < len(message):
cipherText[col] += message[pointer]
cipher_text[col] += message[pointer]
pointer += key
return "".join(cipherText)
return "".join(cipher_text)
def decryptMessage(key: int, message: str) -> str:
def decrypt_message(key: int, message: str) -> str:
"""
>>> decryptMessage(6, 'Hlia rDsahrij')
>>> decrypt_message(6, 'Hlia rDsahrij')
'Harshil Darji'
"""
numCols = math.ceil(len(message) / key)
numRows = key
numShadedBoxes = (numCols * numRows) - len(message)
plainText = [""] * numCols
num_cols = math.ceil(len(message) / key)
num_rows = key
num_shaded_boxes = (num_cols * num_rows) - len(message)
plain_text = [""] * num_cols
col = 0
row = 0
for symbol in message:
plainText[col] += symbol
plain_text[col] += symbol
col += 1
if (
(col == numCols)
or (col == numCols - 1)
and (row >= numRows - numShadedBoxes)
(col == num_cols)
or (col == num_cols - 1)
and (row >= num_rows - num_shaded_boxes)
):
col = 0
row += 1
return "".join(plainText)
return "".join(plain_text)
if __name__ == "__main__":