I was wondering if there is a way to permutate math operations since you can't place them in a list (to my understanding). I want to solve this problem
NUMBERMANIA: Calculate the number 1042 using numbers [1, 2, 9, 2, 59, 974] and basic arithmetic operations (+, -, *, /). Each of the numbers can be used only once.
Using code, my idea is to iterate through every possible permutation of the numbers, which is possible through itertools
, then slot them into a function which does this.
[number1] [math operation] [number2] [math operation] ... [math operation] [number6] e.g 1 * 2 / 9 + 2 / 59 * 974
But the numbers don't have to be in this order, and the math operations don't have to be in that order or in that particular frequency in which it appears.
Is there a way to do something like this with math operations?