Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Roman Numerals by Angelika
def zamiana(a):
x=" "
b='I'
c='V'
d='X'
if (a>9 and a<100):
b='X'
c='L'
d='C'
a=a//10
elif (a>99 and a<1000):
b='C'
c='D'
d='M'
a=a//100
elif (a>999):
b='M'
a=a//1000
if a<4:
x=a*b
elif a==4:
x=b+c
elif a==5:
x=c
elif (a>5 and a<9):
x=c+(a-5)*b
elif a==9:
x=b+d
x=x.strip()
return x
def checkio(data):
liczba=' '
i=1
while data>0:
x=data%10
x=x*i
i=i*10
data=data//10
if x!=0:
x=zamiana(x)
liczba=x+liczba
liczba=liczba.strip()
return(liczba)
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. 28, 2016