Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
replace solution in Creative category for Roman Numerals by Sim0000
def checkio(n):
d = {'IIIII': 'V', 'IIII': 'IV', 'VV': 'X', 'VIV': 'IX',
'XXXXX': 'L', 'XXXX': 'XL', 'LL': 'C', 'LXL': 'XC',
'CCCCC': 'D', 'CCCC': 'CD', 'DD': 'M', 'DCD': 'CM'}
s = 'I' * n
for i in d: s = s.replace(i, d[i])
return s
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'
print('Done! Go Check!')
March 8, 2019
Comments: