学习大神思路然后再码一遍

def cal_24(s, res):
    if len(s) == 1:
        return s[0] == res
    for i in range(len(s)):
        mid = s[i]
        rest = s[:i] + s[i+1:]
        if cal_24(rest, res + mid) \
        or cal_24(rest, res - mid) \
        or cal_24(rest, res / mid) \
        or cal_24(rest, res * mid):
            return True
    return False

while 1:
    try:
        print(f'{cal_24(list(map(int, input().split())), 24)}'.lower())
    except:
        break