# how to generate all possible equations with a set of number and operators?

i got a maths problem, for given that a set of character {1,2,3,4,5,6,7,8,9,+,-,*,/}. and then by using the set of characters to randomly generate 10(or let say N) characters in an array, i.e. $[1,+,1,*,3,5,7,8,1]$. after that I need to find all the possibility of equations by using this array of characters plus 1 character '='.

Therefore in this case, $[1,+,1,*,3,5,7,8,1]$ it would be like the following equations: 1*1=1 , 3+5=8 , 7+1=3+5 , 7+1=8 , 8-1=7 , 15=8+7 , 15+3=18 (maybe more)

it can form multiple digit operation, i.e 15+3=18

so my question is I am trying using a program to generate the equations all. Could you guys give me some ideas what kind of algorithms can do so? or any methods do it? thanks a lot!

have a nice day!

-
Maybe best suited to Stack Overflow? Also just being picky, doesn't 8-1=7 and 7+=3+5 fall outside your inputs as you haven't a - or 2 +s? I like this question it got me to sign into Mathematics! –  glh May 18 '13 at 9:58
each equation should have valid operator. so any equations without operator cannot be accepted. 1=1 is not accepted. –  justicepenny May 18 '13 at 16:23
just post it on stack overflow.... but always stupid and negative ppl just reply with some non sense and "minus" my question, i am getting sick with those pathetic ppl in there. –  justicepenny May 18 '13 at 16:35

Thinking out aloud ;)

1. If you arranged the numbers in all possible ways noting you must have at least 2 numbers and incriminating to the maximum selected.

2. Then reproduce each number set with the = in each valid location. This would be your starting point.

3. Where you can then place the selected modifiers in each valid place.

1. First one at a time.
2. Then combining them one at a time.
4. Then for each iteration check the formulas validity saving or rejecting as required.

This seems quite lengthy but is a place to start. I think there will be some constraints or further optimisations I've not YET thought of you can apply to decrease the number of interactions you'll need to do.