14
1
Challenge
Giving a valid arithmetic sum with some missing numbers, output the full expression.
Example:
1#3 123
+ 45# => + 456
-------- --------
579 579
Input
- Expression format can be an array
["1#3", "45#", "579"]
, a string"1#3+45#=579"
, or 3 inputsf("1#3","45#","579")
Output
- Same as input
- You don't need to output the result
Notes
- The missing numbers are going to be represented using
#
or any other constant non-numeric character you want - Assume result wont have a missing number
- Assume Input/Output consist in 2 terms and a final result
- Assume both term > 0 and result >= 2
- There might be multiple solutions. You can output anyone as long as the sum result match
Test Cases with possibly outputs (pretty format)
#79 879
+ 44# => + 444
-------- --------
1323 1323
5#5 555
+ 3#3 => + 343
-------- --------
898 898
# 1
+ # => + 1
-------- --------
2 2
### 998
+ ### => + 1 PD: there are a lot of possible outputs for this one
-------- --------
999 999
123 123
+ # => + 1
-------- --------
124 124
9 9
+ #6 => + 46
-------- --------
55 55
#123651 1123651
+ #98# => + 7981
------------ -----------
1131632 1131632
Standard code-golf rules apply
Do we need to strip leading zeros? – None – 2018-08-30T14:55:09.363
@Mnemonic not necessarily – Luis felipe De jesus Munoz – 2018-08-30T14:58:47.693
can I take the input with the sides around
=
swapped? e.g.579=1#3+45#
– dzaima – 2018-08-30T15:25:55.287@dzaima yes , no problem – Luis felipe De jesus Munoz – 2018-08-30T15:28:18.613
test-case request:
###+###=2
– dzaima – 2018-08-30T15:43:03.0302"Assume both term > 0" does "assume" mean that I have to output both terms > 0 or that I can assume that there's always a solution with both > 0 but output whatever? – dzaima – 2018-08-30T15:48:03.170
1also your added test-case avoids exactly what I was asking for - the leading zeroes – dzaima – 2018-08-30T15:48:39.290
Distantly related (as in: both require fixing arithmetic equations). – Kevin Cruijssen – 2018-08-31T09:55:05.483
Can I take input with
==
instead of=
? – Titus – 2018-09-10T18:39:34.820