Short Python
def judgePoint24(self, nums):\n        if len(nums) == 1:\n            return math.isclose(nums[0], 24)\n        return any(self.judgePoint24([x] + rest)\n     
    def judgePoint24(self, nums):\n        if len(nums) == 1:\n            return math.isclose(nums[0], 24)\n        return any(self.judgePoint24([x] + rest)\n                   for a, b, *rest in itertools.permutations(nums)\n                   for x in {a+b, a-b, a*b, b and a/b})\n\nJust go through all pairs of numbers `a` and `b` and replace them with `a+b`, `a-b`, `a*b` and `a/b`, . Use recursion for the now smaller list. Positive base case is the list being `[24]` (or close enough).\n\nI prevent division-by-zero by using `b and a/b` instead of just `a/b`. If `b` is zero, then `b and a/b` is zero. And it's ok to have that zero, since `a*b` is zero as well. It's not even a *second* zero, because I'm creating a *set* of the up to four operation results, so duplicates are ignored immediately.\n\nOh and note that I'm using Python 3, so `/` is "true" division, not integer division like in Python 2. And it would be better to use `fractions.Fraction` instead of floats. I actually just realized that there is in fact an input where simple floats fail, namely `[3, 3, 8, 8]`. Floats calculate 23.999999999999989341858963598497211933135986328125 instead of 24. It's not in the judge's test suite, but it should be soon (Edit: it now is). Using `Fraction` however made my solution exceed the time limit, so I settled for the above approximation solution.
[]