Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ciphers/decrypt_caesar_with_chi_squared.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,13 @@ def decrypt_caesar_with_chi_squared(

# Get the most likely cipher by finding the cipher with the smallest chi squared
# statistic
most_likely_cipher: int = min( # type: ignore
chi_squared_statistic_values, # type: ignore
key=chi_squared_statistic_values.get, # type: ignore
) # type: ignore
def chi_squared_statistic_values_sorting_key(key: int) -> tuple[float, str]:
return chi_squared_statistic_values[key]

most_likely_cipher: int = min(
chi_squared_statistic_values,
key=chi_squared_statistic_values_sorting_key,
)

# Get all the data from the most likely cipher (key, decoded message)
(
Expand Down
3 changes: 1 addition & 2 deletions ciphers/polybius.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def numbers_to_letter(self, index1: int, index2: int) -> str:
>>> PolybiusCipher().numbers_to_letter(1, 1) == "a"
True
"""
letter = self.SQUARE[index1 - 1, index2 - 1]
return letter
return self.SQUARE[index1 - 1, index2 - 1]

def encode(self, message: str) -> str:
"""
Expand Down