Python - Backtracking on card permutations
if we have N operands, we have N - 1 points where that would be the "last" operator\nSo for start st and end en, we iterate through all mid points and recursive
if we have N operands, we have N - 1 points where that would be the "last" operator\nSo for start `st` and end `en`, we iterate through all `mid` points and recursively evaluate on `[st, mid]` and `[mid + 1, en]`. We apply all four operators. We add sub solutions to sets and return and expand the solution sets. 24 should exist in solution of `[0, n - 1]`.\nThis gets 85% time of all solutions\n```\ndef judgePoint24(self, nums: List[int]) -> bool:\n        ops = {\'+\': lambda x, y: x + y,\n              \'-\': lambda x, y: x - y,\n              \'/\': lambda x, y: x / y if y != 0 else float(\'inf\'),\n              \'*\': lambda x, y: x * y}\n        \n        def _eval(nums, st, en):\n            if st == en:\n                return set([nums[st]])\n            n = len(nums)\n            ans = []\n            for mid in range(st, en):\n                lefts = _eval(nums, st, mid)\n                rights = _eval(nums, mid + 1, en)\n                for left in lefts:\n                    for right in rights:\n                        for op in ops:\n                            ans.append(ops[op](left, right))\n            return ans\n        for perm_nums in itertools.permutations(nums):\n            for x in _eval(perm_nums, 0, len(perm_nums) - 1):\n                if abs(x - 24) < 0.00005:\n                    return True\n        return False\n```
[]