Python3 - clean code
python\nclass Solution:\n    def judgePoint24(self, cards: List[int]) -> bool:\n        # I use fractions because of floating point arithmetic\n        # size i
```python\nclass Solution:\n    def judgePoint24(self, cards: List[int]) -> bool:\n        # I use fractions because of floating point arithmetic\n        # size is 24 [nums] x 64 [operators] x 2 [precedence]\n        from operator import add, sub, mul\n        from fractions import Fraction\n        from itertools import permutations, product\n\n        def div(x, y):\n            return x / y if y else 0\n\n        operators = [add, sub, mul, div]\n        for (a, b, c, d) in set(permutations(map(Fraction, cards))):  # O(24)\n            for (f1, f2, f3) in product(operators, repeat=3):  # O(64)\n                if f1(d, f2(c, f3(a, b))) == 24 or f1(f2(a, b), f3(c, d)) == 24:  # O(2)\n                    return True\n        return False\n```
[]