题解 | #24点游戏算法#
24点游戏算法
https://www.nowcoder.com/practice/fbc417f314f745b1978fc751a54ac8cb
def f(nums, tar): if len(nums) == 1: return nums[0] == tar for i in range(len(nums)): t = nums[i] c = nums[:i] + nums[i + 1 :] if f(c, tar + t) or f(c, tar - t) or f(c, tar * t) or f(c, tar / t): return True return False ls = list(map(int, input().split())) if f(ls, 24): print("true") else: print("false")