Roman numerals/Decode: Difference between revisions

m
Line 5,393:
characters are unrecognised.
'''
dct = defaultdict(
lambda: goNone,
zip(
x'IVXLCDM',
accumulate(chain([1], cycle([5, 2])), mul)
)
)
 
def go(mb, x):
'''Just a letter value added to or
Line 5,402 ⟶ 5,410:
else:
r, total = mb
return x, total + (-x if x < r else x)
x,
total + (-x if x < r else x)
)
 
dctreturn = defaultdictbindMay(reduce(
lambda: Nonego,
[dct[k.upper()] for k in reversed(list(s))],
zip(
(0, 'IVXLCDM',0)
))(snd)
accumulate(chain([1], cycle([5, 2])), mul)
)
)
return bindMay(
reduce(
go,
[dct[k.upper()] for k in reversed(list(s))],
(0, 0)
)
)(snd)
 
 
Line 5,464 ⟶ 5,460:
 
# snd :: (a, b) -> b
def snd(tplab):
'''Second member of a pair.'''
return tplab[1]
 
 
9,655

edits