Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
simple!! solution in Clear category for Roman Numerals by mfurones
r0 = ['','I','II','III','IV','V','VI','VII','VIII','IX']
r1 = ['','X','XX','XXX','XL','L','LX','LXX','LXXX','XC']
r2 = ['','C','CC','CCC','CD','D','DC','DCC','DCCC','CM']
r3 = ['','M','MM','MMM']
def checkio(data):
a = data%10
b = (data//10)%10
c = (data//100)%10
d = (data//1000)%10
return r3[d]+r2[c]+r1[b]+r0[a]
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'
Dec. 30, 2014
Comments: