[Python3] dp
\n\nfrom fractions import Fraction\n\nclass Solution:\n    def judgePoint24(self, cards: List[int]) -> bool:\n        \n        @cache\n        def fn(*args): \
\n```\nfrom fractions import Fraction\n\nclass Solution:\n    def judgePoint24(self, cards: List[int]) -> bool:\n        \n        @cache\n        def fn(*args): \n            """Return True if arguments can be combined into 24."""\n            if len(args) == 1: return args[0] == 24\n            for x, y, *rem in permutations(args): \n                for op in add, sub, mul, Fraction: \n                    if (op != Fraction or y != 0) and fn(op(x, y), *rem): return True\n            return False \n        \n        return fn(*cards)\n```
['Python3']