Given a set of 6 numbers e.g 1,5,8,9,2,6 and 2 operands e.g + and – i was wondering how you would go about generating all possible valid sums e.g 1+8=9 and so on.
The numbers could be an positive number 0-9 and the operands could be +-/* squared and Square Root
If any one can help i would really appreciate it.
Thanks
“positive number 0-9”
0 is not a positive number.
“the operands could be +-/* squared and Square Root”
The square and the square root do only take one parameter, so how do you apply this over two elements of your list?
As you didn’t specify any language here the solution for the addition as stated in your post:
This allows sums of the same element with itself, if this behaviour is not intended, change it accordingly.
Use other operators as needed.
Very verbose example in C: