DEV Community

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

Collapse
 
greymd profile image
Yasuhiro Yamada • Edited

Solution in Bash and some general commands:

#!/bin/bash
noCarryAddition () {
  p=$(( $1 > $2 ? $1 : $2 ));
  eval paste '<(printf "%${#p}d" $'{1,2}' | grep -o .)' |
    awk '{printf $1+$2}' | awk 4
}

noCarryAddition 2 11   # => 13
noCarryAddition 16 18  # => 214
noCarryAddition 122 81 # => 1103
Collapse
 
petrosapotsos profile image
Petros Apotsos

This reminds me of the quote: "Whatever you do, there is an asian doing it better."
Nice solution!!