Java bringing new meaning to brute force
\nThis is just an Intellij inline-method refactoring of this other ugly solution: https://leetcode.com/problems/24-game/discuss/584767/Java-no-control-flow-(no-
\nThis is just an Intellij inline-method refactoring of this other ugly solution: https://leetcode.com/problems/24-game/discuss/584767/Java-no-control-flow-(no-if-for-while-etc.)-beats-100-time-100-space\n\nFor some reason it\'s much slower and uses much more memory than the version with method calls. Maybe someone who knows more about Java than me can explain why the massive boolean OR expression is slower than method calls. \n\nI would have done more refactoring to take this to its logical conclusion but it got too big for Leetcode so I left it here.\n\n```\n/*\n\nRuntime: 7 ms, faster than 18.69% of Java online submissions for 24 Game.\nMemory Usage: 64.5 MB, less than 6.25% 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\n        return judge(a * b * c * d) || judge(a + b * c * d) || judge(a - b * c * d)\n                || b * c * d != 0 && judge(a / (b * c * d)) || judge(a * (b + c * d))\n                || judge(a + b + c * d) || judge(a - (b + c * d))\n                || b + c * d != 0 && judge(a / (b + c * d)) || judge(a * (b - c * d))\n                || judge(a + b - c * d) || judge(a - (b - c * d))\n                || b - c * d != 0 && judge(a / (b - c * d))\n                || c * d != 0 && (judge(a * (b / (c * d))) || judge(a + b / (c * d))\n                || judge(a - b / (c * d)) || b / (c * d) != 0 && judge(a / (b / (c * d))))\n                || judge(a * c * d * b) || judge(a + c * d * b)\n                || judge(a - c * d * b) || c * d * b != 0 && judge(a / (c * d * b))\n                || judge(a * (c * d + b)) || judge(a + c * d + b)\n                || judge(a - (c * d + b)) || c * d + b != 0 && judge(a / (c * d + b))\n                || judge(a * (c * d - b)) || judge(a + c * d - b)\n                || judge(a - (c * d - b)) || c * d - b != 0 && judge(a / (c * d - b))\n                || b != 0 && (judge(a * (c * d / b)) || judge(a + c * d / b)\n                || judge(a - c * d / b) || c * d / b != 0 && judge(a / (c * d / b)))\n                || judge(b * a * c * d) || judge(b + a * c * d)\n                || judge(b - a * c * d) || a * c * d != 0 && judge(b / (a * c * d))\n                || judge(b * (a + c * d)) || judge(b + a + c * d)\n                || judge(b - (a + c * d)) || a + c * d != 0 && judge(b / (a + c * d))\n                || judge(b * (a - c * d)) || judge(b + a - c * d)\n                || judge(b - (a - c * d)) || a - c * d != 0 && judge(b / (a - c * d))\n                || c * d != 0 && (judge(b * (a / (c * d))) || judge(b + a / (c * d))\n                || judge(b - a / (c * d)) || a / (c * d) != 0 && judge(b / (a / (c * d))))\n                || judge(b * c * d * a) || judge(b + c * d * a)\n                || judge(b - c * d * a) || c * d * a != 0 && judge(b / (c * d * a))\n                || judge(b * (c * d + a)) || judge(b + c * d + a)\n                || judge(b - (c * d + a)) || c * d + a != 0 && judge(b / (c * d + a))\n                || judge(b * (c * d - a)) || judge(b + c * d - a)\n                || judge(b - (c * d - a)) || c * d - a != 0 && judge(b / (c * d - a))\n                || a != 0 && (judge(b * (c * d / a)) || judge(b + c * d / a)\n                || judge(b - c * d / a) || c * d / a != 0 && judge(b / (c * d / a)))\n                || judge(c * d * a * b) || judge(c * d + a * b)\n                || judge(c * d - a * b) || a * b != 0 && judge(c * d / (a * b))\n                || judge(c * d * (a + b)) || judge(c * d + a + b)\n                || judge(c * d - (a + b)) || a + b != 0 && judge(c * d / (a + b))\n                || judge(c * d * (a - b)) || judge(c * d + a - b)\n                || judge(c * d - (a - b)) || a - b != 0 && judge(c * d / (a - b))\n                || b != 0 && (judge(c * d * (a / b)) || judge(c * d + a / b)\n                || judge(c * d - a / b) || a / b != 0 && judge(c * d / (a / b)))\n                || judge(c * d * b * a) || judge(c * d + b * a)\n                || judge(c * d - b * a) || b * a != 0 && judge(c * d / (b * a))\n                || judge(c * d * (b + a)) || judge(c * d + b + a)\n                || judge(c * d - (b + a)) || b + a != 0 && judge(c * d / (b + a))\n                || judge(c * d * (b - a)) || judge(c * d + b - a)\n                || judge(c * d - (b - a)) || b - a != 0 && judge(c * d / (b - a))\n                || a != 0 && (judge(c * d * (b / a)) || judge(c * d + b / a)\n                || judge(c * d - b / a) || b / a != 0 && judge(c * d / (b / a)))\n                || judge(a * b * (c + d)) || judge(a + b * (c + d))\n                || judge(a - b * (c + d)) || b * (c + d) != 0 && judge(a / (b * (c + d)))\n                || judge(a * (b + c + d)) || judge(a + b + c + d)\n                || judge(a - (b + c + d)) || b + c + d != 0 && judge(a / (b + c + d))\n                || judge(a * (b - (c + d))) || judge(a + b - (c + d))\n                || judge(a - (b - (c + d))) || b - (c + d) != 0 && judge(a / (b - (c + d)))\n                || c + d != 0 && (judge(a * (b / (c + d))) || judge(a + b / (c + d))\n                || judge(a - b / (c + d)) || b / (c + d) != 0 && judge(a / (b / (c + d))))\n                || judge(a * (c + d) * b) || judge(a + (c + d) * b)\n                || judge(a - (c + d) * b) || (c + d) * b != 0 && judge(a / ((c + d) * b))\n                || judge(a * (c + d + b)) || judge(a + c + d + b)\n                || judge(a - (c + d + b)) || c + d + b != 0 && judge(a / (c + d + b))\n                || judge(a * (c + d - b)) || judge(a + c + d - b)\n                || judge(a - (c + d - b)) || c + d - b != 0 && judge(a / (c + d - b)) || b != 0 && (\n                judge(a * ((c + d) / b)) || judge(a + (c + d) / b)\n                        || judge(a - (c + d) / b) || (c + d) / b != 0 && judge(a / ((c + d) / b)))\n                || judge(b * a * (c + d)) || judge(b + a * (c + d))\n                || judge(b - a * (c + d)) || a * (c + d) != 0 && judge(b / (a * (c + d)))\n                || judge(b * (a + c + d)) || judge(b + a + c + d)\n                || judge(b - (a + c + d)) || a + c + d != 0 && judge(b / (a + c + d))\n                || judge(b * (a - (c + d))) || judge(b + a - (c + d))\n                || judge(b - (a - (c + d))) || a - (c + d) != 0 && judge(b / (a - (c + d)))\n                || c + d != 0 && (judge(b * (a / (c + d))) || judge(b + a / (c + d))\n                || judge(b - a / (c + d)) || a / (c + d) != 0 && judge(b / (a / (c + d))))\n                || judge(b * (c + d) * a) || judge(b + (c + d) * a)\n                || judge(b - (c + d) * a) || (c + d) * a != 0 && judge(b / ((c + d) * a))\n                || judge(b * (c + d + a)) || judge(b + c + d + a)\n                || judge(b - (c + d + a)) || c + d + a != 0 && judge(b / (c + d + a))\n                || judge(b * (c + d - a)) || judge(b + c + d - a)\n                || judge(b - (c + d - a)) || c + d - a != 0 && judge(b / (c + d - a)) || a != 0 && (\n                judge(b * ((c + d) / a)) || judge(b + (c + d) / a)\n                        || judge(b - (c + d) / a) || (c + d) / a != 0 && judge(b / ((c + d) / a)))\n                || judge((c + d) * a * b) || judge(c + d + a * b)\n                || judge((c + d) - a * b) || a * b != 0 && judge((c + d) / (a * b))\n                || judge((c + d) * (a + b)) || judge(c + d + a + b)\n                || judge((c + d) - (a + b)) || a + b != 0 && judge((c + d) / (a + b))\n                || judge((c + d) * (a - b)) || judge(c + d + a - b)\n                || judge((c + d) - (a - b)) || a - b != 0 && judge((c + d) / (a - b)) || b != 0 && (\n                judge((c + d) * (a / b)) || judge(c + d + a / b)\n                        || judge((c + d) - a / b) || a / b != 0 && judge((c + d) / (a / b)))\n                || judge((c + d) * b * a) || judge(c + d + b * a)\n                || judge((c + d) - b * a) || b * a != 0 && judge((c + d) / (b * a))\n                || judge((c + d) * (b + a)) || judge(c + d + b + a)\n                || judge((c + d) - (b + a)) || b + a != 0 && judge((c + d) / (b + a))\n                || judge((c + d) * (b - a)) || judge(c + d + b - a)\n                || judge((c + d) - (b - a)) || b - a != 0 && judge((c + d) / (b - a)) || a != 0 && (\n                judge((c + d) * (b / a)) || judge(c + d + b / a)\n                        || judge((c + d) - b / a) || b / a != 0 && judge((c + d) / (b / a)))\n                || judge(a * b * (c - d)) || judge(a + b * (c - d))\n                || judge(a - b * (c - d)) || b * (c - d) != 0 && judge(a / (b * (c - d)))\n                || judge(a * (b + c - d)) || judge(a + b + c - d)\n                || judge(a - (b + c - d)) || b + c - d != 0 && judge(a / (b + c - d))\n                || judge(a * (b - (c - d))) || judge(a + b - (c - d))\n                || judge(a - (b - (c - d))) || b - (c - d) != 0 && judge(a / (b - (c - d)))\n                || c - d != 0 && (judge(a * (b / (c - d))) || judge(a + b / (c - d))\n                || judge(a - b / (c - d)) || b / (c - d) != 0 && judge(a / (b / (c - d))))\n                || judge(a * (c - d) * b) || judge(a + (c - d) * b)\n                || judge(a - (c - d) * b) || (c - d) * b != 0 && judge(a / ((c - d) * b))\n                || judge(a * (c - d + b)) || judge(a + c - d + b)\n                || judge(a - (c - d + b)) || c - d + b != 0 && judge(a / (c - d + b))\n                || judge(a * (c - d - b)) || judge(a + c - d - b)\n                || judge(a - (c - d - b)) || c - d - b != 0 && judge(a / (c - d - b)) || b != 0 && (\n                judge(a * ((c - d) / b)) || judge(a + (c - d) / b)\n                        || judge(a - (c - d) / b) || (c - d) / b != 0 && judge(a / ((c - d) / b)))\n                || judge(b * a * (c - d)) || judge(b + a * (c - d))\n                || judge(b - a * (c - d)) || a * (c - d) != 0 && judge(b / (a * (c - d)))\n                || judge(b * (a + c - d)) || judge(b + a + c - d)\n                || judge(b - (a + c - d)) || a + c - d != 0 && judge(b / (a + c - d))\n                || judge(b * (a - (c - d))) || judge(b + a - (c - d))\n                || judge(b - (a - (c - d))) || a - (c - d) != 0 && judge(b / (a - (c - d)))\n                || c - d != 0 && (judge(b * (a / (c - d))) || judge(b + a / (c - d))\n                || judge(b - a / (c - d)) || a / (c - d) != 0 && judge(b / (a / (c - d))))\n                || judge(b * (c - d) * a) || judge(b + (c - d) * a)\n                || judge(b - (c - d) * a) || (c - d) * a != 0 && judge(b / ((c - d) * a))\n                || judge(b * (c - d + a)) || judge(b + c - d + a)\n                || judge(b - (c - d + a)) || c - d + a != 0 && judge(b / (c - d + a))\n                || judge(b * (c - d - a)) || judge(b + c - d - a)\n                || judge(b - (c - d - a)) || c - d - a != 0 && judge(b / (c - d - a)) || a != 0 && (\n                judge(b * ((c - d) / a)) || judge(b + (c - d) / a)\n                        || judge(b - (c - d) / a) || (c - d) / a != 0 && judge(b / ((c - d) / a)))\n                || judge((c - d) * a * b) || judge(c - d + a * b)\n                || judge((c - d) - a * b) || a * b != 0 && judge((c - d) / (a * b))\n                || judge((c - d) * (a + b)) || judge(c - d + a + b)\n                || judge((c - d) - (a + b)) || a + b != 0 && judge((c - d) / (a + b))\n                || judge((c - d) * (a - b)) || judge(c - d + a - b)\n                || judge((c - d) - (a - b)) || a - b != 0 && judge((c - d) / (a - b)) || b != 0 && (\n                judge((c - d) * (a / b)) || judge(c - d + a / b)\n                        || judge((c - d) - a / b) || a / b != 0 && judge((c - d) / (a / b)))\n                || judge((c - d) * b * a) || judge(c - d + b * a)\n                || judge((c - d) - b * a) || b * a != 0 && judge((c - d) / (b * a))\n                || judge((c - d) * (b + a)) || judge(c - d + b + a)\n                || judge((c - d) - (b + a)) || b + a != 0 && judge((c - d) / (b + a))\n                || judge((c - d) * (b - a)) || judge(c - d + b - a)\n                || judge((c - d) - (b - a)) || b - a != 0 && judge((c - d) / (b - a)) || a != 0 && (\n                judge((c - d) * (b / a)) || judge(c - d + b / a)\n                        || judge((c - d) - b / a) || b / a != 0 && judge((c - d) / (b / a)))\n                || d != 0 && (judge(a * b * (c / d)) || judge(a + b * (c / d))\n                || judge(a - b * (c / d)) || b * (c / d) != 0 && judge(a / (b * (c / d)))\n                || judge(a * (b + c / d)) || judge(a + b + c / d)\n                || judge(a - (b + c / d)) || b + c / d != 0 && judge(a / (b + c / d))\n                || judge(a * (b - c / d)) || judge(a + b - c / d)\n                || judge(a - (b - c / d)) || b - c / d != 0 && judge(a / (b - c / d))\n                || c / d != 0 && (judge(a * (b / (c / d))) || judge(a + b / (c / d))\n                || judge(a - b / (c / d)) || b / (c / d) != 0 && judge(a / (b / (c / d))))\n                || judge(a * (c / d) * b) || judge(a + c / d * b)\n                || judge(a - c / d * b) || c / d * b != 0 && judge(a / (c / d * b))\n                || judge(a * (c / d + b)) || judge(a + c / d + b)\n                || judge(a - (c / d + b)) || c / d + b != 0 && judge(a / (c / d + b))\n                || judge(a * (c / d - b)) || judge(a + c / d - b)\n                || judge(a - (c / d - b)) || c / d - b != 0 && judge(a / (c / d - b)) || b != 0 && (\n                judge(a * (c / d / b)) || judge(a + c / d / b)\n                        || judge(a - c / d / b) || c / d / b != 0 && judge(a / (c / d / b)))\n                || judge(b * a * (c / d)) || judge(b + a * (c / d))\n                || judge(b - a * (c / d)) || a * (c / d) != 0 && judge(b / (a * (c / d)))\n                || judge(b * (a + c / d)) || judge(b + a + c / d)\n                || judge(b - (a + c / d)) || a + c / d != 0 && judge(b / (a + c / d))\n                || judge(b * (a - c / d)) || judge(b + a - c / d)\n                || judge(b - (a - c / d)) || a - c / d != 0 && judge(b / (a - c / d))\n                || c / d != 0 && (judge(b * (a / (c / d))) || judge(b + a / (c / d))\n                || judge(b - a / (c / d)) || a / (c / d) != 0 && judge(b / (a / (c / d))))\n                || judge(b * (c / d) * a) || judge(b + c / d * a)\n                || judge(b - c / d * a) || c / d * a != 0 && judge(b / (c / d * a))\n                || judge(b * (c / d + a)) || judge(b + c / d + a)\n                || judge(b - (c / d + a)) || c / d + a != 0 && judge(b / (c / d + a))\n                || judge(b * (c / d - a)) || judge(b + c / d - a)\n                || judge(b - (c / d - a)) || c / d - a != 0 && judge(b / (c / d - a)) || a != 0 && (\n                judge(b * (c / d / a)) || judge(b + c / d / a)\n                        || judge(b - c / d / a) || c / d / a != 0 && judge(b / (c / d / a)))\n                || judge((c / d) * a * b) || judge(c / d + a * b)\n                || judge(c / d - a * b) || a * b != 0 && judge(c / d / (a * b))\n                || judge(c / d * (a + b)) || judge(c / d + a + b)\n                || judge(c / d - (a + b)) || a + b != 0 && judge(c / d / (a + b))\n                || judge(c / d * (a - b)) || judge(c / d + a - b)\n                || judge(c / d - (a - b)) || a - b != 0 && judge(c / d / (a - b)) || b != 0 && (\n                judge(c / d * (a / b)) || judge(c / d + a / b)\n                        || judge(c / d - a / b) || a / b != 0 && judge(c / d / (a / b)))\n                || judge((c / d) * b * a) || judge(c / d + b * a)\n                || judge(c / d - b * a) || b * a != 0 && judge(c / d / (b * a))\n                || judge(c / d * (b + a)) || judge(c / d + b + a)\n                || judge(c / d - (b + a)) || b + a != 0 && judge(c / d / (b + a))\n                || judge(c / d * (b - a)) || judge(c / d + b - a)\n                || judge(c / d - (b - a)) || b - a != 0 && judge(c / d / (b - a)) || a != 0 && (\n                judge(c / d * (b / a)) || judge(c / d + b / a)\n                        || judge(c / d - b / a) || b / a != 0 && judge(c / d / (b / a))));\n    }\n\n    private boolean judge(double a) {\n        return Math.abs(a - 24) < 0.000001;\n    }\n}\n```
['Java']