Few days ago I was thinking about finding algorithm for the following problem, and I got some ideas, but still not covering all the cases:
The algorithm takes as input:
100234190 = 227
The output should be:
100+2+34+1+90 = 227
This means that the program should place the "+" sign such that the sum equal 227.
1. Check the whole number (100234190) if <= 227
2. If not, then cut the rightmost digit (10023419), and repeat 1.
3. Once the condition is achieved, then
Store the number, say X e.g., that achieved the condition
do: 227 - X
re-do steps from 1. using (100234190) but without X, i.e. if X was 100, then
I will start step 1. again with 234190.
Note: the algorithm checks about the leftmost zeros, but I did not mention this.
The algorithm doesn't work for all cases, I think that I need to maintain the sum every each step, but I don't know how.