Java no control flow (no if, for, while, etc.), beats 100% time, 100% space
With only 4 inputs this problem can be solved with basically only booleans and math operations.\n\nThis code doesn\'t make any assumptions about the inputs bein
With only 4 inputs this problem can be solved with basically only booleans and math operations.\n\nThis code doesn\'t make any assumptions about the inputs being in the range 1-9, they could be any integers and it would still work fine- the solutions that encode all possible answers only work with 1-9 inputs.\n\nThis solution does a bunch of unecessary operations (e.g. calculates both ```a * b``` and ```b * a``` but with no control flow it just blazes through the calculations and doesn\'t worry about it. \n\nI tried inlining most of the methods here, and for some reason that made things a lot slower: https://leetcode.com/problems/24-game/discuss/584772/Java-bringing-new-meaning-to-brute-force\n\n```\n/*\n\nRuntime: 0 ms, faster than 100.00% of Java online submissions for 24 Game.\nMemory Usage: 36.5 MB, less than 100.00% of Java online submissions for 24 Game.\n\n*/\n\nclass Solution {\n    public boolean judgePoint24(int[] nums) {\n\n        double a = Double.valueOf(nums[0]);\n        double b = Double.valueOf(nums[1]);\n        double c = Double.valueOf(nums[2]);\n        double d = Double.valueOf(nums[3]);\n        \n        return judge(a, b, c, d)\n            || judge(a, b, d, c)\n            || judge(a, c, b, d)\n            || judge(a, c, d, b)\n            || judge(a, d, b, c)\n            || judge(a, d, c, b)\n            || judge(b, a, c, d)\n            || judge(b, a, d, c)\n            || judge(b, c, a, d)\n            || judge(b, c, d, a)\n            || judge(b, d, a, c)\n            || judge(b, d, c, a)\n            || judge(c, a, b, d)\n            || judge(c, a, d, b)\n            || judge(c, b, a, d)\n            || judge(c, b, d, a)\n            || judge(c, d, a, b)\n            || judge(c, d, b, a)\n            || judge(d, a, b, c)\n            || judge(d, a, c, b)\n            || judge(d, b, a, c)\n            || judge(d, b, c, a)\n            || judge(d, c, a, b)\n            || judge(d, c, b, a);\n    }\n    \n    private boolean judge(double a, double b, double c, double d) {\n        return judge(a, b, c*d)\n            || judge(a, b, c+d)\n            || judge(a, b, c-d)\n            || d != 0 && judge(a, b, c/d);\n    }\n\n    private boolean judge(double a, double b, double c) {\n        return judge3(a, b, c)\n            || judge3(a, c, b)\n            || judge3(b, a, c)\n            || judge3(b, c, a)\n            || judge3(c, a, b)\n            || judge3(c, b, a);\n    }    \n\n    private boolean judge3(double a, double b, double c) {\n        return judge(a, b*c)\n            || judge(a, b+c)\n            || judge(a, b-c)\n            || c != 0 && judge(a, b/c);\n    }    \n\n    private boolean judge(double a, double b) {\n        return judge(a*b)\n            || judge(a+b)\n            || judge(a-b)\n            || b != 0 && judge(a/b);\n    }    \n\n    private boolean judge(double a) {\n        return Math.abs(a - 24) < 0.000001;\n    }\n}\n```
['Java']