Hack Forums
zomg one-liner hell - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: zomg one-liner hell (/showthread.php?tid=2513480)



zomg one-liner hell - Mapex - May 20, 2012

Code
for (int a = 1; a <= 500; a++)
            for (int b = 1; b <= 500; b++)
                for (int c = 1; c <= 500; c++)
                    if (a < b && b < c)
                        if ((Math.pow(a, 2) + Math.pow(b, 2)) == Math.pow(c, 2))                    
                            if (a+b+c == 1000)
                                return (new int[] {a, b, c});

wat is this madness


* - ChineseFountain - May 20, 2012

Nested for loops and if loops...????


* - infamousnoone - May 20, 2012

An attempted solution for http://projecteuler.net/problem=9 (is what it is)
See http://en.wikipedia.org/wiki/Pythagorean_triple