Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Roman Numerals by Sioul
def checkio(data):
def nem(number, mult=1, big='X', mid='V', smol='I'):
#mult = 10 ** (len(str(number)) - 1)
rep = ''
if number >= 9 * mult:
rep += smol + big
elif number >= 5* mult:
rep += mid + ((number // mult) - 5) * smol
elif number >= 4 * mult:
rep += smol + mid
elif number >= 1 * mult:
rep += (number // mult) * smol
return rep
return ((data // 1000) * 'M'
+ nem(data % 1000, 100, 'M', 'D', 'C')
+ nem(data % 100, 10, 'C', 'L', 'X')
+ nem(data % 10))
Sept. 20, 2019