Skip to content

Commit dd13fe2

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 6bff121 commit dd13fe2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

conversions/roman_numerals.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
(4, "IV"),
2626
(1, "I"),
2727
]
28+
29+
2830
def roman_to_int(roman: str) -> int:
2931
"""
3032
Convert a Roman numeral to an integer, supporting Vinculum notation
@@ -45,13 +47,15 @@ def roman_to_int(roman: str) -> int:
4547
i, total = 0, 0
4648
while i < len(roman):
4749
# Check for 2-character symbols first (like I_ or X_)
48-
if i + 1 < len(roman) and roman[i:i+2] in vals:
49-
total += vals[roman[i:i+2]]
50+
if i + 1 < len(roman) and roman[i : i + 2] in vals:
51+
total += vals[roman[i : i + 2]]
5052
i += 2
5153
else:
5254
total += vals[roman[i]]
5355
i += 1
5456
return total
57+
58+
5559
def int_to_roman(number: int) -> str:
5660
"""
5761
Convert an integer to a Roman numeral, supporting Vinculum notation
@@ -74,7 +78,9 @@ def int_to_roman(number: int) -> str:
7478
if number == 0:
7579
break
7680
return "".join(result)
77-
81+
82+
7883
if __name__ == "__main__":
7984
import doctest
85+
8086
doctest.testmod()

0 commit comments

Comments
 (0)