import java.util.*;

public class Grid
{
    public Grid (Vector<String> instructions, boolean debug)
    {
        _input = instructions;
        _theGrid = new Vector<CoordinatePair>();
        _debug = debug;

        findSquare();
    }

    public final Vector<CoordinatePair> getBeamGrid ()
    {
        return _theGrid;
    }

    private final void findSquare ()
    {
        int startY = 10;
        int startX = 0;

        Coordinate leftCoord = leftCoordinate(startY, startX);
        Coordinate rightCoord = rightCoordinate(leftCoord.getY(), leftCoord.getX());

        for (int i = startY + 1; i < 3000; i++)
        {
            leftCoord = leftCoordinate(i, leftCoord.getX());
            rightCoord = rightCoordinate(i, rightCoord.getX());

            System.out.println("adding "+leftCoord+" "+rightCoord);

            _theGrid.add(new CoordinatePair(leftCoord, rightCoord));
        }
    }

    private Coordinate leftCoordinate (int y, int x)
    {
        Intcode computer = new Intcode(_input, _debug);

        System.out.println("leftPointer "+x+" "+y);

        computer.setInputs(""+x, ""+y);
        computer.executeProgram();

        Vector<String> outputs = computer.getOutputs();
        Enumeration<String> iter = outputs.elements();
        boolean beingPulled = false;

        while (iter.hasMoreElements() && !beingPulled)
        {
            String value = iter.nextElement();

            if (DroneStatus.BEING_PULLED.equals(value))
                beingPulled = true;
        }

        if (!beingPulled)  // keep going until we start being pulled
            return leftCoordinate(y, x +1);
        else
            return new Coordinate(x, y);
    }

    private Coordinate rightCoordinate (int y, int x)
    {
        Intcode computer = new Intcode(_input, _debug);

        System.out.println("rightPointer "+x+" "+y);

        computer.setInputs(""+x, ""+y);
        computer.executeProgram();

        Vector<String> outputs = computer.getOutputs();
        Enumeration<String> iter = outputs.elements();
        boolean beingPulled = true;

        while (iter.hasMoreElements() && beingPulled)
        {
            String value = iter.nextElement();

            if (DroneStatus.STATIONARY.equals(value))
                beingPulled = false;
        }

        if (beingPulled)  // keep going until we stop being pulled
            return rightCoordinate(y, x +1);
        else
            return new Coordinate(x -1, y);
    }

    private Vector<String> _input;
    private Vector<CoordinatePair> _theGrid;
    private boolean _debug;
}
@@ -34,16 +34,64 @@
  Grid%0A%7B%0A
+    public static final int GRID_FUDGE = 2000;%0A%0A
     publ
@@ -143,16 +143,16 @@
  debug)%0A
-
     %7B%0A  
@@ -442,17 +442,36 @@
 rtY = 10
-;
+0;  // far enough in
 %0A       
@@ -678,12 +678,18 @@
 i %3C 
-3000
+GRID_FUDGE
 ; i+
@@ -831,77 +831,8 @@
 );%0A%0A
-            System.out.println(%22adding %22+leftCoord+%22 %22+rightCoord);%0A%0A
     
@@ -1033,61 +1033,8 @@
 );%0A%0A
-        System.out.println(%22leftPointer %22+x+%22 %22+y);%0A%0A
     
@@ -1696,32 +1696,32 @@
 y, int x)%0A    %7B%0A
+
         Intcode 
@@ -1765,62 +1765,8 @@
 );%0A%0A
-        System.out.println(%22rightPointer %22+x+%22 %22+y);%0A%0A
     

Update Grid.java