9
9
def roman_to_int (roman : str ) -> int :
10
10
"""
11
11
Convert a Roman numeral to an integer, supporting Vinculum notation (underscore _ represents 1000 times).
12
- LeetCode No. 13 Roman to Integer
13
- Given a roman numeral, convert it to an integer.
14
- Input is guaranteed to be within the range from 1 to 3999.
15
- https://en.wikipedia.org/wiki/Roman_numerals
12
+ LeetCode No. 13 Roman to Integer
13
+ Given a roman numeral, convert it to an integer.
14
+ Input is guaranteed to be within the range from 1 to 3999.
15
+ https://en.wikipedia.org/wiki/Roman_numerals
16
16
>>> all(roman_to_int(key) == value for key, value in tests.items())
17
17
>>> tests = {"III": 3, "CLIV": 154, "MIX": 1009, "MMD": 2500, "MMMCMXCIX": 3999, "I_V_": 4000, "X_": 10000, "M_": 1000000}
18
18
>>> all(roman_to_int(key) == value for key, value in tests.items())
@@ -34,7 +34,7 @@ def roman_to_int(roman: str) -> int:
34
34
def int_to_roman (number : int ) -> str :
35
35
"""
36
36
Convert an integer to a Roman numeral, supporting Vinculum notation (underscore _ represents 1000 times).
37
- Given a integer, convert it to an roman numeral.
37
+ Given a integer, convert it to an roman numeral.
38
38
https://en.wikipedia.org/wiki/Roman_numerals
39
39
>>> tests = {"III": 3, "CLIV": 154, "MIX": 1009, "MMD": 2500, "MMMCMXCIX": 3999, "I_V_": 4000, "X_": 10000, "M_": 1000000}
40
40
>>> all(int_to_roman(value) == key for key, value in tests.items())
0 commit comments