Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Roman solution in Clear category for Roman Numerals by Alexander.Meta
def checkio(numbers):
roman = ({'1':'I','2':'II','3':'III','4':'IV','5':'V','6':'VI','7':'VII','8':'VIII','9':'IX','0':''},
{'1':'X','2':'XX','3':'XXX','4':'XL','5':'L','6':'LX','7':'LXX','8':'LXXX','9':'XC','0':''},
{'1':'C','2':'CC','3':'CCC','4':'CD','5':'D','6':'DC','7':'DCC','8':'DCCC','9':'CM','0':''},
{'1':'M','2':'MM','3':'MMM','0':''})
in_roman = []
for p,n in enumerate (reversed (str(numbers))):
in_roman.insert(0,roman[p][n])
return ''.join(in_roman)
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'
Nov. 26, 2015