3 ms·
this code is so smart, maybe because it is Python after all from operator import add expr = "28+32+++32++39" print reduce(add, map(int, filter(bool
by ghostdiver 13y ago
this code is so smart, maybe because it is Python after all
from operator import add
expr = "28+32+++32++39"
print reduce(add, map(int, filter(bool, expr.split("+"))))
but in JavaScript it looks much more readable:
"28+32+++32++39".split(/([\+]+)/g).reduce((r,v) => r+v, 0);