From ad28671b3b85014a1722ba800aa36ea4755442f3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 08:19:12 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- conversions/roman_numerals.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/conversions/roman_numerals.py b/conversions/roman_numerals.py index 4752b37e4..61c3eb0bc 100644 --- a/conversions/roman_numerals.py +++ b/conversions/roman_numerals.py @@ -8,7 +8,7 @@ ROMAN = [ ] def roman_to_int(roman: str) -> int: """ - Convert a Roman numeral to an integer, supporting Vinculum notation + Convert a Roman numeral to an integer, supporting Vinculum notation (underscore _ represents 1000 times). LeetCode No. 13 Roman to Integer: @@ -26,7 +26,7 @@ def roman_to_int(roman: str) -> int: "I_": 1000, "V_": 5000, "X_": 10000, "L_": 50000, "C_": 100000, "D_": 500000, "M_": 1000000 } - + i, total = 0, 0 while i < len(roman): if i + 1 < len(roman) and roman[i:i+2] in vals: @@ -36,11 +36,11 @@ def roman_to_int(roman: str) -> int: total += vals[roman[i]] i += 1 return total - + def int_to_roman(number: int) -> str: """ - Convert an integer to a Roman numeral, supporting Vinculum notation + Convert an integer to a Roman numeral, supporting Vinculum notation (underscore _ represents 1000 times). Given an integer, convert it to a Roman numeral. @@ -61,7 +61,7 @@ def int_to_roman(number: int) -> str: if number == 0: break return "".join(result) - + if __name__ == "__main__": import doctest doctest.testmod()