DEV Community

Discussion on: Daily Challenge #287 - 16+18=214

Collapse
 
rafaacioly profile image
Rafael Acioly

Python 🐍

Not the solution i like but it does the job.


def sum_(first: int, second: int) -> int:
  first_mapped = str(first)
  second_mapped = str(second)

  # Fill the smallest list with '0' on left
  if len(first_mapped) > len(second_mapped):
    second_mapped = second_mapped.zfill(len(first_mapped))
  elif len(second_mapped) > len(first_mapped):
    first_mapped = first_mapped.zfill(len(second_mapped))

  result = ''
  for x, y in zip(first_mapped, second_mapped):
    result += str(int(x) + int(y))

  return int(result)