Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Roman Numerals by KarolinaK
def checkio(data):
result=""
help=data%10
i=0
jed=('I','V','X','L','C','D','M')
while data>0 :
print(help)
if(help<4):
result=jed[i]*int(help)+result
elif(help==4):
result=jed[i]+jed[i+1]+result
elif(help>=5 and help<9):
help2=help%5
result=jed[i+1]+jed[i]*int(help2)+result
elif(help==9):
result=jed[i]+jed[i+2]+result
i+=2
print(data)
data=(data-data%10)/10
help=data%10
print(data)
print(result)
return result
#replace this for solution
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. 17, 2016