题解 | #24点游戏算法#
24点游戏算法
http://www.nowcoder.com/practice/fbc417f314f745b1978fc751a54ac8cb
def fun(num_list, target): if len(num_list) == 1: return num_list[0] == target else: for i in range(len(num_list)): list1 = num_list[:i] + num_list[i+1:] n = num_list[i] if fun(list1, target + n) or fun(list1, target - n) or fun(list1, target * n) or fun(list1, target / n): return True else: return False
num_list = [int(i) for i in input().split()] if fun(num_list, 24): print('true') else: print('false')