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