import java.util.*;

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

    public Vector<Tile> arrangement (Vector<Tile> tiles)
    {
        Vector<Tile> toReturn = new Vector<Tile>();
        int dimension = (int) Math.sqrt((double) tiles.size());

        if (_debug)
            System.out.println("Dimensions "+dimension+" by "+dimension);

        for (int i = 0; i < tiles.size(); i++)
        {
            Tile t = tiles.elementAt(i);

            numberOfMatchingEdges(t, tiles);
        }

        return toReturn;
    }

    private int numberOfMatchingEdges (Tile toCheck, Vector<Tile> tiles)
    {
        for (int i = 0; i < tiles.size(); i++)
        {
            Tile t = tiles.elementAt(i);
            int number = 0;

            if (!t.equals(toCheck))  // don't compare with ourself!
            {
                for (int j = 0; j < 4; j++)
                {
                    for (int k = 0; k < 4; k++)
                    {
                        if (t.getEdges()[j].equals(toCheck.getEdges()[k]))
                            number++;
                    }
                }

                System.out.println("Tile "+t.getID()+" shares "+number+" common edges with tile "+toCheck.getID());
            }
        }

        return 0;
    }

    private boolean _debug;
}
@@ -493,35 +493,27 @@
         
-numberOfM
+m
 atching
-Edg
+Til
 es(t, ti
@@ -577,31 +577,32 @@
 ate 
-int numberOfM
+Vector%3CTile%3E m
 atching
-Edg
+Til
 es (
@@ -633,32 +633,84 @@
 e%3E tiles)%0A    %7B%0A
+        Vector%3CTile%3E matches = new Vector%3CTile%3E();%0A%0A
         for (int
@@ -807,22 +807,35 @@
     
-int number = 0
+boolean matchedEdge = false
 ;%0A%0A 
@@ -951,13 +951,31 @@
  0; 
+(
 j %3C 4
+) && !matchedEdge
 ; j+
@@ -1168,63 +1168,252 @@
     
-    number++;%0A                    %7D%0A                %7D%0A%0A
+%7B%0A                            matchedEdge = true;%0A                            break;%0A                        %7D%0A                    %7D%0A                %7D%0A%0A                if (matchedEdge)%0A                %7B%0A                    matches.add(t);%0A%0A    
     
@@ -1473,19 +1473,8 @@
 ares
- %22+number+%22
  com
@@ -1513,16 +1513,34 @@
 tID());%0A
+                %7D%0A
         
@@ -1571,17 +1571,23 @@
  return 
-0
+matches
 ;%0A    %7D%0A

Update Solver.java