I'm willing to make a program that evaluates all possible combinations of operations ( + , - , * , / ) on a set of positive integers of length 6 (eg : [1, 6, 3, 9, 2, 9] ).
To do so, I am using the list
symbols = ['+', '-', '*', '/']
and wrote a nested loop to create all possibilities
+ + + + +
+ + + + -
.
.
.
/ / / / *
/ / / / /
by calling each row (eg : + - + * / ) a motif, and M the set of all motifs where
M[0] = ['+', '+', '+', '+', '+']
M[1] = ['+', '+', '+', '+', '-']
and so on. My goal now would be to write a function
evaluate_expression(motif, a, b, c, d, e, f)
that spits out the result of the expression a motif[0] b motif[1] c motif[2] d motif[3] e motif[4] f
my idea was to try converting '+' into the symbol + but I couldn't find a way to do it, I hope some of you guys here would know how to do that, I'm open to any suggestion of modification to make this cleaner.