Sha256: bb36fbce25e37e3cf49fe41026e6280e6db63496403058e3060f6eae2b867aea

Contents?: true

Size: 399 Bytes

Versions: 396

Compression:

Stored size: 399 Bytes

Contents

NUMERAL_MAPPINGS = (
    (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 numeral(number):
    s = ''
    for arabic, roman in NUMERAL_MAPPINGS:
        while number >= arabic:
            s += roman
            number -= arabic
    return s

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.179 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.178 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.177 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.176 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.175 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.174 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.173 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.172 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.171 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.170 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.169 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.167 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.166 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.165 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.164 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.163 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.162 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.161 tracks/python/exercises/roman-numerals/example.py
trackler-2.2.1.160 tracks/python/exercises/roman-numerals/example.py