2019-01-26 08:34:45 +08:00

5 lines
289 B
Python

def diffWaysToCompute(self, input):
return [a + b if c == '+' else a - b if c == '-' else a * b \
for i, c in enumerate(input) if c in '+-*' \
for a in self.diffWaysToCompute(input[:i]) \
for b in self.diffWaysToCompute(input[i+1:])] or [int(input)]