fork download
  1. from functools import reduce
  2.  
  3. DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}
  4.  
  5. def str2int(s):
  6. def fn(x, y):
  7. return x * 10 + y
  8. def char2num(s):
  9. return DIGITS[s]
  10. return reduce(fn, map(char2num, s))
  11.  
  12. # your code goes here
Success #stdin #stdout 0.1s 14180KB
stdin
Standard input is empty
stdout
Standard output is empty