Solve an equation with (almost) any numbers you like Given a string of the characters +=- where there is at least one =, insert positive integers between all the symbols and at the start and the end such that the math equations are satisfied.

For example, given the input

+-=-=


you need to insert positive integers A through F like this

A+B-C=D-E=F


such that the equations are all satisfied, i.e. A + B - C and D - E and F are all the same number.

There are many possible ways to do this since, as long as the equations work out, any set of positive integers may be used. Each line here is a possible valid output to input +-=-=:

2+3-4=6-5=1
1+1-1=2-1=1
4+2-4=4-2=2
100+1-10=182-91=91
89+231-77=1024-781=243


Note that the value of the expressions is not required to be a positive integer like the inserted numbers are. For example, given input -=- the outputs 1-10=8-17 (evals to -9) and 10-1=17-8 (evals to 9) are both equally valid. Of course for some inputs such as = it's impossible to have a negative as the expression since only positive numbers like 5=5 can be inserted.

Note also that zero is not a positive integer.

The shortest code in bytes wins.

You may output the numbers as a list instead of inserting them directly into the string. If you do output the string there may be spaces separating symbols and numbers. So, for input +-=-=, outputting

2, 3, 4, 6, 5, 1


or

2 + 3 - 4 = 6 - 5 = 1


is equivalent to outputting

2+3-4=6-5=1


Test Cases

Input | One Possible Output
= | 1=1
== | 2=2=2
+= | 1+3=4
=+ | 2=1+1
-= | 30-10=20
=- | 1=2-1
=-= | 3=7-4=3
=+= | 2=1+1=2
=== | 100=100=100=100
+=- | 3+2=7-2
-=+ | 7-2=3+2
+=+ | 3+3=3+3
-=- | 1-10=8-17
--= | 60-1-1=58
++= | 60+1+1=62
-+= | 60-9+1=52
+-= | 60+9-1=68
+-=-= | 2+3-4=6-5=1
--=-- | 2-1-1=2-1-1
==-== | 47=47=50-3=47=47
=++=+-=-+=--= | 3=1+1+1=3+1-1=1-1+3=5-1-1=3
+--++-=-+-+- | 35+10-16-29+20+107-1000=5-4+3-2+1-876
====== | 8=8=8=8=8=8=8
Retina, 58 bytes

[-+]
$&amp;1
\B((\+1)|(-1))*
$._$*1$#3$*1$#2$*_$&amp;
+`1_

1+
$.&amp;


Try it online!

Alternative solution at the same byte count:

((\+)|(-))*
$._$*1$#3$*1$#2$*_$&amp;
+`1_

([+-])1*
$+1
1+
$.&amp;


Try it online!

Explanation

The basic idea is to turn all the +s and -s into simple +1 and -1 operations and then to prepend a sufficiently large number that makes all the equations work. To make the equations match, we can simply prepend the same number to each of them, and then reduce it by one for each +1 and increase it by one for each -1 after it. Since we'll be working with unary numbers, the only catch is that the first number needs to be large enough that we can reduce it by 1 enough times.

[-+]
$&amp;1


We start by inserting a 1 after each - or +.

\B((\+1)|(-1))*
$._$*1$#3$*1$#2$*_$&amp;


The \B ensures that these matches are either at the beginning of the input, or between a = and a + or -, i.e. all the positions where we want to insert the leading number of an expression. The  ((\+1)|(-1))* part then simply counts the number of +1s and -1s in groups 2 and 3 respectively. Now let's break down the substitution string:

$._$*1   # For each character in the current string, insert a 1. This is
         # an offset which is the same for each expression and is guaranteed
         # to be large enough that all subsequent +1s can be cancelled.
$#3$*1   # For each -1, insert a 1.
$#2$*_   # For each +1, insert a _.
$&amp;       # Re-insert the string of +1s and -1s.


+`1_



Repeatedly drop 1_ from the string, applying the required cancellation from the +1s.

1+
$.&amp;


Finally, replace all the strings of 1s with their lengths to convert from unary to decimal.