[Python] 2 clean recursive solutions O(N^N)
Solution 1: Use itertools to get all the combinations. Then we recursively execute each possible operator in the list until we have one element leftover.\n\n\nd
__Solution 1__: Use itertools to get all the combinations. Then we recursively execute each possible operator in the list until we have one element leftover.\n\n```\ndef judgePoint24(self, cards: List[int]) -> bool:\n    def dfs(pos):\n        if len(pos) == 1 and round(pos[0], 1) == 24:\n            return True\n        for (i,a),(j,b) in itertools.combinations(enumerate(pos), 2):\n            for x in [a+b, a-b, b-a, a*b, b and a/b, a and b/a]:\n                if dfs([x]+[v for idx,v in enumerate(pos) if idx not in [i,j]]):\n                    return True\n        return False\n    return dfs(cards)\n```\n__Solution 2__: Instead of using itertools we can calculate the combinations ourselves. Again complexity is `O(N^N)`.\n```\ndef judgePoint24(self, cards: List[int]) -> bool:\n    def dfs(pos):\n        if len(pos) == 1 and round(pos[0],1) == 24: return True\n        for i,a in enumerate(pos):\n            pos_copy = pos[:i] + pos[i+1:]\n            for j in range(i+1, len(pos)):\n                b = pos[j]\n                for x in [a+b, a-b, b-a, a*b, b and a/b, a and b/a]:\n                    pos_copy[j-1] = x\n                    if dfs(pos_copy): return True\n                    pos_copy[j-1] = b\n        return False\n    return dfs(cards)\n```
['Backtracking', 'Recursion', 'Combinatorics', 'Python']