0
\$\begingroup\$

This question already has an answer here:

The Challenge

You must create a program that does addition using string manipulation, similar to:

 999
+  1
----
1000

Which means the maximum amount of addition possible is 9+9+9. And your code should handle numbers up to infinity (since the addition is done on strings).

Breakdown of 999+1

addend #1 + addend #2 + carry
Step 1:

9+1+0=10, result=0, carry=1, output=0.

Step 2:

9+0+1=10, result=0, carry=1, output=00.

Step 3:

9+0+1=10, result=0, carry=1, output=000.

Step 4:

0+0+1=1, result=1, carry=0, output=1000.
Final output=1000

If your code does this, you did it correctly.

Rules

  • Standard code golf, least amount of characters wins.

  • Nothing silly, your code must work with all addition problems, and no "In my language "a" does just this!".

  • Proper loopholes (those that aren't ridiculous) apply.


This is different from "Adding Two Numbers" because...

You must use string manipulation and must add the numbers character by character, there are restrictions past "1+1", you must do "last char of 187+last char of 988".

\$\endgroup\$

marked as duplicate by DJMcMayhem, mbomb007, AdmBorkBork, acrolith, Conor O'Brien code-golf Nov 14 '16 at 19:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    \$\begingroup\$ I'm sorry, but this challenge makes too many assumptions about language features. What's "String manipulation"? See X without Y \$\endgroup\$ – Nathan Merrill Nov 14 '16 at 19:10
  • \$\begingroup\$ String manipulation in the sense of getting characters x through y, many languages have that feature, maybe not golfing languages, but code golf doesn't have to have golfing answers. \$\endgroup\$ – ender_scythe Nov 14 '16 at 19:29