Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Roman Numerals by AndriusMk
def checkio(number):
def sb(S, N):
return "".join(S[int(i)] for i in ",0,00,000,01,1,10,100,1000,02".split(",")[N]) if N > 0 else ""
numerals = "IVXLCDM"
return "".join(reversed([sb(numerals[i*2:], int(number / 10**i) % 10) for i in range(0,4)]))
if __name__ == '__main__':
assert checkio(6) == 'VI', 'First'
assert checkio(76) == 'LXXVI', 'Second'
assert checkio(499) == 'CDXCIX', 'Third'
assert checkio(3888) == 'MMMDCCCLXXXVIII', 'Fourth'
print('All ok')
Nov. 29, 2012