Problem:
The numbers from 1 to 10 are given. Put the equal sign(somewhere between them) and any arithmetic operator {+ - * /} so that a perfect integer equality is obtained(both the final result and the partial results must be integer)
Example:
1*2*3*4*5/6+7=8+9+10
1*2*3*4*5/6+7-8=9+10
My first idea to resolve this was using backtracking:
- Generate all possibilities of putting operators between the numbers
- For one such possibility replace all the operators, one by one, with the equal sign and check if we have two equal results
But this solution takes a lot of time.
So, my question is: Is there a faster solution, maybe something that uses the operator properties or some other cool math trick ?