Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Composition of Functions (thanks to veky's derelict battery heads-up) solution in Clear category for Reverse Roman Numerals by flpo
from functools import reduce
from re import Scanner
from operator import itemgetter
compose = lambda *funcs: lambda x: reduce(lambda y, f: f(y), reversed(funcs), x)
ROMANS = (
('IV', 4),
('IX', 9),
('XL', 40),
('XC', 90),
('CD', 400),
('CM', 900),
('I', 1),
('V', 5),
('X', 10),
('L', 50),
('C', 100),
('D', 500),
('M', 1000)
)
reverse_roman = compose(sum, itemgetter(0), Scanner(ROMANS).scan)
July 15, 2017
Comments: