import java.util.*;

public class XMAS
{
    public XMAS (boolean debug)
    {
        _debug = debug;
    }

    public Vector<Integer> validate (Vector<Integer> input, int preamble)
    {
        Vector<Integer> invalid = new Vector<Integer>();
        int index = 0;

        for (int i = preamble; i < input.size(); i++)
        {
            if (!sums(input.elementAt(i), input, index, preamble))
                invalid.add(input.elementAt(i));
            
            index++;
        }

        return invalid;
    }

    private boolean sums (int total, Vector<Integer> input, int start, int preamble)
    {
        for (int i = start; i < (start + preamble -1); i++)
        {
            if (_debug)
                System.out.println("Trying to total "+total+" using "+input.elementAt(i)+" and "+input.elementAt(i +1));

            if (input.elementAt(i) + input.elementAt(i +1) == total)
            {
                if (_debug)
                    System.out.println("Total "+total+" found.");

                return true;
            }
        }

        if (_debug)
            System.out.println(total+" is not the sum of two entries.");

        return false;
    }

    private boolean _debug;
}
@@ -673,32 +673,104 @@
  i++)%0A        %7B%0A
+            for (int j = i +1; j %3C preamble - i; j++)%0A            %7B%0A    
             if (
@@ -769,32 +769,36 @@
     if (_debug)%0A
+    
                 
@@ -898,17 +898,18 @@
 tAt(
-i +1
+j
 ));%0A%0A
+    
     
@@ -957,20 +957,17 @@
 ementAt(
-i +1
+j
 ) == tot
@@ -974,34 +974,42 @@
 al)%0A            
+   
+ 
 %7B%0A
+    
                 
@@ -1012,32 +1012,36 @@
     if (_debug)%0A
+    
                 
@@ -1103,24 +1103,28 @@
             
+    
 return true;
@@ -1124,16 +1124,34 @@
 n true;%0A
+                %7D%0A
         

Update XMAS.java