My new hero John Connor submitted an epic code snippet.  Let us dissect this in two parts, because it is such a massive SOD that trying to tackle it all at once could cause brain trauma. 

John Connor is supposed to grade a JAVA programming assignment, and so he must read through and attempt to understand student code ...

Part 1: The Comment

There is a large comment at the top of a particular student's assignment.  Actually, it isn't a comment so much as it is an apology... the code we are about to see is so bad, the programmer felt remorse in advance for John Connor:

/** To the grader:
         I realize that by now, you are in either a complete state of shock or disgust at the length of my program.  
Perhaps even both. To this, I deeply apologize that I can offer no consolation. I, myself, am quite ashamed  of this
program, and can speak no more good of this massive blob of text other than that it *should* work.         

         If it doesn't, then please feel free to dock as many points as necessary to vent your frustration that you,  
of all TAs, chose the unlucky pile that contained my program, for I too would be quite vindictive while grading.    

         I also realize that this program is a messy compilation of inefficient coding, and perhaps even stands as
something blasphemous in your eyes. Coming midterms forced me to write the program as is because this format required
the least amount of thinking as well as the least amount of time. Therefore, I only ask one thing of you: Be gentle.
*/


We can find many WTF's just in this comment.  For example, why would anyone volunteer to a grader, in writing no less, the right to "dock as many points as necessary"?


Part 2: The Code
 
*John Connor* aptly describes the code: "The student, two-thirds of the way through an Intro Programming (in Java) course at a major private university, didn't bother to learn loops.  His assignment, a slightly modified Conway's Game of Life simulation on a 20x20 grid, therefore took more than 1700 lines to implement. (And in the end, it only half-worked.)"
 
I tried to follow the code, and I give props to *John Connor*, because this code reads like a JAVA Obfuscated Logic contest winner.  I am shocked that it works at all!

public static int getTestcell()
      {
         int i, neighbor, male, female, empty, value, num;
         male = 0;
         female = 0;
         empty = 0;
         value = 0;
         num = 0;
         if (spotvalue[n] == 0)
         {
            neighbor = n;
            if (n == 0)
            {
               if (spotvalue[neighbor + 1] == 0)
                  empty = empty + 1;
               else
               {
                  if (spotvalue[neighbor + 1] == 1)
                     male = male + 1;
                  if (spotvalue[neighbor + 1] == 2)
                     female = female + 1;
               }
               if (spotvalue[neighbor + 20] == 0)
                  empty = empty + 1;
               else
               {
                  if (spotvalue[neighbor + 20] == 1)
                     male = male + 1;
                  if (spotvalue[neighbor + 20] == 2)
                     female = female + 1;
               }
               if (spotvalue[neighbor + 21] == 0)
                  empty = empty + 1;
               else
               {
                  if (spotvalue[neighbor + 21] == 1)
                     male = male + 1;
                  if (spotvalue[neighbor + 21] == 2)
                     female = female + 1;
               }
               if (male >= 1 && male <=2)
               {
                  if (male == female)
                  {
                     num = rand.nextInt(2);
                     value = num + 1;
                     return value;
                  }
                  else
                  {
                     value = 0;
                     return value;
                  }
               }
               else
               {
                  value = 0;
                  return value;
               }       
            }
            if (n == 19)
            {
               if (spotvalue[neighbor - 1] == 0)
                  empty = empty + 1;
               else
               {
                  if (spotvalue[neighbor - 1] == 1)
                     male = male + 1;
                  if (spotvalue[neighbor - 1] == 2)
                     female = female + 1;
               }
               if (spotvalue[neighbor + 20] == 0)
                  empty = empty + 1;
               else
               {
                  if (spotvalue[neighbor + 20] == 1)
                     male = male + 1;
                  if (spotvalue[neighbor + 20] == 2)
                     female = female + 1;
               }
               if (spotvalue[neighbor + 19] == 0)
                  empty = empty + 1;
               else
               {
                  if (spotvalue[neighbor + 19] == 1)
                     male = male + 1;
                  if (spotvalue[neighbor + 19] == 2)
                     female = female + 1;
               }
               if (male >= 1 && male <=2)
               {
                  if (male == female)
                  {
                     num = rand.nextInt(2);
                     value = num + 1;
                     return value;
                  }
                  else
                  {
                     value = 0;
                     return value;
                  }
               }
               else
               {
                  value = 0;
                  return value;
               }       
            }
            if (n == 380)
            {
               if (spotvalue[neighbor + 1] == 0)
                  empty = empty + 1;
               else
               {
                  if (spotvalue[neighbor + 1] == 1)
                     male = male + 1;
                  if (spotvalue[neighbor + 1] == 2)
                     female = female + 1;
               }
               if (spotvalue[neighbor - 20] == 0)
                  empty = empty + 1;
               else
               {
                  if (spotvalue[neighbor - 20] == 1)
                     male = male + 1;
                  if (spotvalue[neighbor - 20] == 2)
                     female = female + 1;
               }
               if (spotvalue[neighbor - 19] == 0)
                  empty = empty + 1;
... (continues for a very, very long time!)