Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Two letter mapping trick solution in Speedy category for Roman Numerals by twilyght
ROMAN = {
1000: 'M', 900: 'CM',
500: 'D', 400: 'CD',
100: 'C', 90: 'XC',
50: 'L', 40: 'XL',
10: 'X', 9: 'IX',
5: 'V', 4: 'IV',
1: 'I'
}
def checkio(data):
result = ''
remainder = data
mapping_iterator = iter(ROMAN.items())
while remainder:
value, symbols = next(mapping_iterator)
count = remainder // value
remainder -= value * count
result += symbols * count
return result
May 10, 2020