Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Roman Numerals by CyprianSzlachciak
def checkio(data):
#replace this for solution
napis = ""
while data >= 1000:
data-=1000
napis+="M"
if data >=900:
napis+="CM"
data-=900
if data >= 500:
data-=500
napis+="D"
if data >= 400:
data-=400
napis+="CD"
while data >=100:
napis+="C"
data-=100
if data >= 90:
data-=90
napis+="XC"
if data >=50:
data-=50
napis+="L"
if data>=40:
napis+="XL"
data-=40
while data >= 10:
data-=10
napis+="X"
while data >= 9:
data-=9
napis+="IX"
while data >= 5:
data-=5
napis+="V"
while data >= 4:
data-=4
napis+="IV"
while data >= 1:
data-=1
napis+="I"
return napis
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