I saw some examples of getting combinations of "operations" and "numbers" as well as "functions" and "numbers". But I was unable to combine all of them together.
import operator
import itertools
numbers = [9, 0, 1]
operators = ['+', '-']
funcs = [math.log, math.exp]
for v1, v2 in itertools.permutations(numbers, 2):
for op, fn in itertools.product(operators, funcs):
print(f"{op}({v1}, {fn}({v2})) =", op(v1, fn(v2)))
The above is an example code to get combinations for a value and a function but this is not what I want.
Combinations of Numbers and Operators - This link provides a suitable method to combine all numbers and operators.
Now, how do I combine everything and get output like:
9 + log(1)
0 + exp(9)
1 - exp(9) + log(0)
1 + log(9+0)
9 - exp(0+1)
...
Note: Operators can be re-used but not the 'numbers'.
All possible combinations need to be listed.
Any solutions will be greatly appreciated :) I am stuck in solving this!!