Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Roman Numerals by Yuleidy_Navarro
def checkio(data):
import math
Unidades= ['','I','II','III','IV','V','VI','VII','VIII','IX']
Decenas= ['','X','XX','XXX','XL','L','LX','LXX','LXXX','XC']
Centenas= ['','C','CC','CCC','CD','D','DC','DCC','DCCC','CM']
mil= data//1000
numeroromano=''
numeroromano+= 'M'* mil
unidad= data%10
decena= int(math.floor(data/10))%10
centena=int(math.floor(data/100))%10
if (data>=100):
numeroromano+= Centenas[centena]+ Decenas[decena]+Unidades[unidad]
elif (data>=10):
numeroromano+= Decenas[decena]+Unidades[unidad]
else:
numeroromano+= Unidades[unidad]
return numeroromano
#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'
Jan. 12, 2017