Simple, clean python (beats 98%)
\timport itertools\n\tclass Solution:\n\t\tdef judgePoint24(self, cards: List[int]) -> bool:\n\n\t\t\t@lru_cache(None)\n\t\t\tdef helper(nums):\n\t\t\t\tif(len(
\timport itertools\n\tclass Solution:\n\t\tdef judgePoint24(self, cards: List[int]) -> bool:\n\n\t\t\t@lru_cache(None)\n\t\t\tdef helper(nums):\n\t\t\t\tif(len(nums) == 1):\n\t\t\t\t\treturn nums\n\t\t\t\t\t\n\t\t\t\tpossible = set()\n\t\t\t\tfor i in range(1, len(nums)):\n\t\t\t\t\tleft = helper(nums[0:i])\n\t\t\t\t\tright = helper(nums[i:])\n\t\t\t\t\tfor l in left:\n\t\t\t\t\t\tfor r in right:\n\t\t\t\t\t\t\tpossible.update([l+r, l-r, l*r, r and l/r])\n\t\t\t\treturn possible\n\n\t\t\tfor perm in itertools.permutations(cards):\n\t\t\t\tans = helper(perm)\n\t\t\t\tif(any([abs(24-n)<=0.001 for n in ans])):\n\t\t\t\t\treturn True\n\n\t\t\treturn False\n
[]