Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Roman Numerals by PawelMartyniuk
def checkio(data):
def function(data, data2, number):
data = data % data2
count = data // number
return count
str = 'M' * function(data, 5000, 1000) + 'D' * function(data, 1000, 500) + 'C' * function(data, 500, 100) + 'L' * function(data, 100, 50) + 'X' * function(data, 50, 10) + 'V' * function(data, 10, 5) + 'I' * function(data, 5, 1)
str = str.replace('VIIII','IX')
str = str.replace('XVVVV','VL')
str = str.replace('LXXXX','XC')
str = str.replace('CLLLL','LD')
str = str.replace('DCCCC','CM')
str = str.replace('CCCC','CD')
str = str.replace('IIII','IV')
str = str.replace('XXXX','XL')
return str
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio(6) == 'VI', '6'
assert checkio(76) == 'LXXVI', '76'
assert checkio(499) == 'CDXCIX', '499'
assert checkio(3888) == 'MMMDCCCLXXXVIII', '3888'
Oct. 24, 2016
Comments: