News for hackers. Stuff that matters.
Re:A Quick Puzzle to Test Your Problem Solving by mikeash on Thursday July 02, 2015 @01:58PM (#9820505)
I'd prefer an example along the lines of:

    for(i = j; i < j + 2; i++) {}
With your example it's easy to lose the distinction between "would eventually terminate if you had a fast computer and a lot of time" and "never terminates even in theory." Here, it definitely looks like it should always run two iterations to matter what the numbers are (as long as they're finite), but it doesn't.

Either way, though, it is definitely hilarious!

Re:A Quick Puzzle to Test Your Problem Solving by eru on Friday July 03, 2015 @12:43AM (#9823526)
Thanks to undefined behaviour, C compilers can assume that you get exactly two iterations for this kind of loop on ints.