Roman Number Parser

Roman numerals may look unusual, but they follow a small set of clear rules. Given a string s containing a Roman numeral, return its value as a regular integer. Account for both normal addition and subtractive pairs such as IV, IX, XL, XC, CD, and CM.

Примеры

Ввод
"III"
Вывод
3
Ввод
"IV"
Вывод
4
Ввод
"IX"
Вывод
9

Нужно реализовать

def roman_to_int(s):

Теги

stringshashmapmath
PostgreSQLv16

Här visas resultatet av din kod

Visible tests
1
Input
"III"
Expected3
2
Input
"IV"
Expected4
3
Input
"IX"
Expected9
4
Input
"LVIII"
Expected58
5
Input
"MCMXCIV"
Expected1994
6
Input
"MMXXVI"
Expected2026
Focus radio
Paused · SomaFM · Fluid