2
def judgePoint24(self, cards: List[int]) -> bool:3
return self.allComputeWays(cards, 4, 24)5
def allComputeWays(self, nums, l, target):7
if abs(nums[0] - target) <= 1e-6:10
for first in range(l):11
for second in range(first + 1, l):12
tmp1, tmp2 = nums[first], nums[second]13
nums[second] = nums[l - 1]15
nums[first] = tmp1 + tmp216
if self.allComputeWays(nums, l - 1, target):18
nums[first] = tmp1 - tmp219
if self.allComputeWays(nums, l - 1, target):21
nums[first] = tmp2 - tmp122
if self.allComputeWays(nums, l - 1, target):24
nums[first] = tmp1 * tmp225
if self.allComputeWays(nums, l - 1, target):28
nums[first] = tmp1 / tmp229
if self.allComputeWays(nums, l - 1, target):32
nums[first] = tmp2 / tmp133
if self.allComputeWays(nums, l - 1, target):35
nums[first], nums[second] = tmp1, tmp2