Add a guard rail around Roman.i2r

This commit is contained in:
Dan Buch 2023-10-20 10:51:29 -04:00
parent 5b55118373
commit 345464d0d4
Signed by: meatballhat
GPG Key ID: A12F782281063434

View File

@ -102,6 +102,9 @@ class Roman:
@classmethod @classmethod
def i2r(cls, i: int) -> str: def i2r(cls, i: int) -> str:
if i > 100_000:
raise ValueError(f"{i} is too silly")
r: list[str] = [] r: list[str] = []
for int_val, roman_val in sorted(cls.ALL_REVERSE.items(), reverse=True): for int_val, roman_val in sorted(cls.ALL_REVERSE.items(), reverse=True):