13
1
Totally not inspired by Visualize long division with ASCII art ;)
Your job is to show long hand addition with ASCII art. You solve longhand addition by adding up the columns right to left, placing the value of the ones place in the result, and carrying the tens place over to the top of the next column.
Input
Input can come basically in any format you want, just as long as you take from 2 to 9 numbers as input.
Output
The formatting here likely matches how you learned it in school:
carry row
number1
number2
...
+ numX
--------
result
You can have just about any amount of trailing whitespace you want here ;)
Examples
50, 50
1
50
+50
---
100
1651, 9879
1111
1651
+9879
-----
11530
6489789, 9874, 287
1122
6489789
9874
+ 287
--------
6499950
Visualize long subtraction with ASCII art: Coming straight to you in 6 months – CalculatorFeline – 2016-02-25T01:13:07.503
Not quite, it's on my list ;) – J Atkin – 2016-02-25T01:14:25.590
1Actually I was taught to put the carry row under the result. – Neil – 2016-02-25T01:15:40.067
1How should we handle
9+9+9+9+9+9+9+9+9+9+9+9+9
? – Downgoat – 2016-02-25T04:15:46.2101@Downgoat ...
you take from 2 to 9 numbers as input
... – PurkkaKoodari – 2016-02-25T08:34:11.690@Pietu1998 Yeah, I didn't want to figure out how to carry one hundred :\ – J Atkin – 2016-02-25T14:16:21.410
To generalize to larger number of input values, we could place spaces between each integer and adjust as appropriate, but this changes the challenge a bit. (Maybe more than just a bit) Or, I guess the extra bits would just need to be added to the appropriate columns, easy peasy, right? :) – Robert Benson – 2016-02-25T14:47:32.170
@CatsAreFluffy a tricky part with subtraction might be the strikethrough for borrowing. – None – 2016-02-25T15:14:43.457
@MichaelT It could, but I have an idea for how it would work. – J Atkin – 2016-02-25T15:18:29.863