Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Roman Numerals by mozurin
def checkio(data):
builtStr = ''
for charDef in (
(1000, 'M'),
(500, 'D'),
(100, 'C'),
(50, 'L'),
(10, 'X'),
(5, 'V'),
(1, 'I'),
):
builtStr += charDef[1] * (data // charDef[0])
data = data % charDef[0]
for repMap in (
('DCCCC', 'CM'),
('CCCC', 'CD'),
('LXXXX', 'XC'),
('XXXX', 'XL'),
('VIIII', 'IX'),
('IIII', 'IV'),
):
builtStr = builtStr.replace(*repMap)
return builtStr
July 7, 2018
Comments: