I have a very hard problem (well for me anyway), and i need help!
Given a list of integers (positive integeres only), the program inserts one equality sign and arithmetic operators between the numbers so that ALL valid equations are obtained. The order of the integers in the list have to be maintained. For example the query equate([1,2,3,4,5])? outputs:
1 = 2 / (3 + (4 - 5))
1 = 2 / (3 + 4 - 5 )
1 = 2 - 3 * (4 - 5)
1 = (2 - 3) / (4 - 5)
1 = (2 - 3) * 4 + 5
1 * 2 = 3 + (4 - 5)
1 * 2 = 3 + 4 - 5
1 * (2 - 3) = 4 - 5
1 / (2 - 3) = 4 - 5
(1 + 2) * 3 = 4 + 5
1 * 2 - 3 = 4 - 5
1 - (2 - 3) * 4 = 5
(1 + 2) * 3 - 4 = 5
(1 + 2) / 3 + 4 = 5
**yes
Basically if the = is replaced by a =:= then the answer to the corressponding equation being tested should be yes, no other rules apply.
I welcome anyone who could help me with this problem in any way!
Given a list of integers (positive integeres only), the program inserts one equality sign and arithmetic operators between the numbers so that ALL valid equations are obtained. The order of the integers in the list have to be maintained. For example the query equate([1,2,3,4,5])? outputs:
1 = 2 / (3 + (4 - 5))
1 = 2 / (3 + 4 - 5 )
1 = 2 - 3 * (4 - 5)
1 = (2 - 3) / (4 - 5)
1 = (2 - 3) * 4 + 5
1 * 2 = 3 + (4 - 5)
1 * 2 = 3 + 4 - 5
1 * (2 - 3) = 4 - 5
1 / (2 - 3) = 4 - 5
(1 + 2) * 3 = 4 + 5
1 * 2 - 3 = 4 - 5
1 - (2 - 3) * 4 = 5
(1 + 2) * 3 - 4 = 5
(1 + 2) / 3 + 4 = 5
**yes
Basically if the = is replaced by a =:= then the answer to the corressponding equation being tested should be yes, no other rules apply.
I welcome anyone who could help me with this problem in any way!