import java.util.*;

/**
 * Loop through the tiles and find out how many of them have matching edges. Then,
 * based upon the number of shared edges we do the following:
 * 
 * 0: ERROR!!
 * 1: If a tile has only one matching edge, then it's easy to say where it needs
 * to be placed.
 * 2: Work outwards from the centre.
 */

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

    /*
     * This time we need to solve the image and return the entire
     * thing assembled, i.e., not just the corners.
     */

    public Vector<Tile> solve (Vector<Tile> tiles)
    {
        HashMap<Long, Integer> tileTable = new HashMap<Long, Integer>();
	
        for (int i = 0; i < tiles.size(); i++)
        {
            Tile t = tiles.elementAt(i);

            tileTable.put(t.getID(), i);
        }

	    System.out.println("**GOT "+tileTable);

        return null;
    } 

    private boolean connects (Tile theTile, Tile toCheck)
    {
        if (_debug)
            System.out.println("Checking "+toCheck.getID()+" against "+theTile.getID());
        
        for (int i = 0; i < 4; i++)
        {
            if (theTile.connectBottomToTop(toCheck) || theTile.connectTopToBottom(toCheck) ||
                theTile.connectLeftToRight(toCheck) || theTile.connectRightToLeft(toCheck))
            {
                return true;
            }

            if (!toCheck.isFrozen())
                toCheck.rotate();
        }
        
        if (!toCheck.isFrozen())
            toCheck.invert();

        for (int i = 0; i < 4; i++)
        {
            if (theTile.connectBottomToTop(toCheck) || theTile.connectTopToBottom(toCheck) ||
                theTile.connectLeftToRight(toCheck) || theTile.connectRightToLeft(toCheck))
            {
                return true;
            }

            if (!toCheck.isFrozen())
                toCheck.rotate();
        }

        return false;
    }

    private boolean _debug;
}
@@ -873,24 +873,656 @@
 ileTable);%0A%0A
+%09    HashSet%3CTile%3E visited = new HashSet%3CTile%3E();%0A%09    LinkedList%3CTile%3E queue = new LinkedList%3CTile%3E();%0A%09%0A        queue.add(tiles.get(0));%0A%0A%09    while (!queue.isEmpty())%0A        %7B%0A            Tile current = queue.poll();%0A            %0A            visited.add(current);%0A%0A            for (int j = 0; j %3C tiles.size(); j++)%0A            %7B%0A                Tile t = tiles.elementAt(j);%0A%0A                if (!visited.contains(t) && !current.equals(t))%0A                %7B%0A                    if (connects(current, t))%0A                        queue.add(t);%0A                %7D%0A%09        %7D%0A%09    %7D%0A%0A%09    System.out.println(%22**NOW have %22+visited);%0A%0A
         retu

Update Solver.java