import java.util.*;

public class Verifier
{
    public static final String EXAMPLE_DATA = "example.txt";

    public Verifier (boolean debug)
    {
        _debug = debug;
    }

    public boolean verify ()
    {
        Vector<Category> cats = Util.loadCategories(EXAMPLE_DATA, _debug);
        Vector<Ticket> ticks = Util.loadTickets(EXAMPLE_DATA, _debug);
        Vector<Ticket> validTickets = Util.validTickets(cats, ticks);

        if (_debug)
        {
            for (int j = 0; j < validTickets.size(); j++)
                System.out.println(validTickets.elementAt(j));
        }

        Vector<Category> results = new Vector<Category>();

        for (int c = 0; c < validTickets.elementAt(0).values().length; c++)
        {
            System.out.println();

            int[] firsts = new int[ticks.size() -1];

            for (int i = 0; i < firsts.length; i++)
                firsts[i] = ticks.elementAt(i+1).values()[c];

            for (int k = 0; k < cats.size(); k++)
            {
                boolean valid = true;

                for (int l = 0; l < firsts.length; l++)
                {
                    if (cats.elementAt(k).valid(firsts[l]))
                    {
                        System.out.println("Category "+cats.elementAt(k)+" is valid for "+firsts[l]);
                    }
                    else
                    {
                        System.out.println("Category "+cats.elementAt(k)+" is invalid for "+firsts[l]);

                        valid = false;
                        break;
                    }
                }

                if (valid)
                {
                    if (!results.contains(cats.elementAt(k)))
                        results.add(cats.elementAt(k));
                }
            }
        }

        System.out.println();

        for (int m = 0; m < results.size(); m++)
        {
            System.out.println("Element "+m+" maps to category "+results.elementAt(m));
        }

        return false;
    }

    private boolean _debug;
}
@@ -100,16 +100,159 @@
 .txt%22;%0A%0A
+    public static final String FIRST = %22row%22;%0A    public static final String SECOND = %22class%22;%0A    public static final String THIRD = %22seat%22;%0A%0A
     publ
@@ -769,212 +769,72 @@
 s = 
-new Vector%3CCategory%3E();%0A%0A        for (int c = 0; c %3C validTickets.elementAt(0).values().length; c++)%0A        %7B%0A            System.out.println();%0A%0A            int%5B%5D firsts = new int%5Bticks.size() -1%5D;%0A%0A    
+Util.order(validTickets, cats);%0A%0A        System.out.println();%0A%0A
     
@@ -850,257 +850,36 @@
 int 
-i
+m
  = 0; 
-i %3C firsts.length; i++)%0A                firsts%5Bi%5D = ticks.elementAt(i+1).values()%5Bc%5D;%0A%0A            for (int k = 0; k %3C cats.size(); k++)%0A            %7B%0A                boolean valid = true;%0A%0A                for (int l = 0; l %3C firsts.length; l
+m %3C results.size(); m
 ++)%0A
@@ -882,32 +882,24 @@
 ++)%0A        
-        
 %7B%0A          
@@ -904,294 +904,51 @@
     
-        if (cats.elementAt(k).valid(firsts%5Bl%5D))%0A                    %7B%0A                        System.out.println(%22Category %22+cats.elementAt(k)+%22 is valid for %22+firsts%5Bl%5D);%0A                    %7D%0A                    else%0A                    %7B%0A                        System.out.println(%22C
+System.out.println(%22Element %22+m+%22 maps to c
 ateg
@@ -953,18 +953,21 @@
 egory %22+
-ca
+resul
 ts.eleme
@@ -975,348 +975,144 @@
 tAt(
-k)+%22 is invalid for %22+firsts%5Bl%5D);%0A%0A                        valid = false;%0A                        break;%0A                    %7D%0A                %7D%0A%0A                if (valid)%0A                %7B%0A                    if (!results.contains(cats.elementAt(k)))%0A                        results.add(cats.elementAt(k));%0A                %7D%0A            %7D
+m));%0A        %7D%0A%0A        if (FIRST.equals(results.elementAt(0).getType()) &&%0A            SECOND.equals(results.elementAt(1).getType()) &&
 %0A   
@@ -1120,187 +1120,91 @@
     
-%7D%0A%0A
     
-    System.out.println();%0A%0A        for (int m = 0; m %3C results.size(); m++)%0A        %7B%0A            System.out.println(%22Element %22+m+%22 maps to category %22+results.elementAt(m))
+THIRD.equals(results.elementAt(2).getType()))%0A        %7B%0A            return true
 ;%0A  

Update Verifier.java