Skip to content

Commit 5c05335

Browse files
authored
hill_cipher.py: Use int() to gracefully deal with float input (TheAlgorithms#12833)
* TheAlgorithms#12821 (comment)
1 parent cd3c3c3 commit 5c05335

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ciphers/hill_cipher.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ def replace_digits(self, num: int) -> str:
7878
'T'
7979
>>> hill_cipher.replace_digits(26)
8080
'0'
81+
>>> hill_cipher.replace_digits(26.1)
82+
'0'
8183
"""
82-
return self.key_string[(num)]
84+
return self.key_string[int(num)]
8385

8486
def check_determinant(self) -> None:
8587
"""

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy