import java.util.*;

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

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

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

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

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

            if (DroneStatus.STATIONARY.equals(value))
            {
                x++;

                computer = new Intcode(_input, _debug);

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

        return new Coordinate(x, y);
    }

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

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

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

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

            if (DroneStatus.BEING_PULLED.equals(value))
            {
                x++;

                computer = new Intcode(_input, _debug);

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

        return new Coordinate(x -1, y);
    }

    private Vector<String> _input;
    private boolean _debug;
}
@@ -145,22 +145,768 @@
    _
-debug = debug;
+theGrid = new Vector%3CCoordinatePair%3E();%0A        _debug = debug;%0A%0A        findSquare();%0A    %7D%0A%0A    public final Vector%3CCoordinatePair%3E getBeamGrid ()%0A    %7B%0A        return _theGrid;%0A    %7D%0A%0A    private final void findSquare ()%0A    %7B%0A        int startY = 10;%0A        int startX = 0;%0A%0A        Coordinate leftCoord = leftCoordinate(startY, startX);%0A        Coordinate rightCoord = rightCoordinate(leftCoord.getY(), leftCoord.getX());%0A%0A        for (int i = startY + 1; i %3C 3000; i++)%0A        %7B%0A            leftCoord = leftCoordinate(i, leftCoord.getX());%0A            rightCoord = rightCoordinate(i, rightCoord.getX());%0A%0A            System.out.println(%22adding %22+leftCoord+%22 %22+rightCoord);%0A%0A            _theGrid.add(new CoordinatePair(leftCoord, rightCoord));%0A        %7D
 %0A   
@@ -1017,32 +1017,85 @@
 nput, _debug);%0A%0A
+        System.out.println(%22leftPointer %22+x+%22 %22+y);%0A%0A
         computer
@@ -1256,32 +1256,69 @@
 puts.elements();
+%0A        boolean beingPulled = false;
 %0A%0A        while 
@@ -1332,32 +1332,48 @@
 asMoreElements()
+ && !beingPulled
 )%0A        %7B%0A    
@@ -1448,18 +1448,20 @@
 tus.
-STATIONARY
+BEING_PULLED
 .equ
@@ -1484,34 +1484,48 @@
         
-%7B%0A
     
-    
+beingPulled = true;%0A
         
 x++;%0A%0A  
@@ -1508,36 +1508,33 @@
 = true;%0A        
-x++;
+%7D
 %0A%0A              
@@ -1531,173 +1531,130 @@
     
-        computer = new Intcode(_input, _debug);%0A%0A                computer.setInputs(%22%22+x, %22%22+y);%0A                computer.executeProgram();%0A            %7D%0A        %7D%0A%0A
+if (!beingPulled)  // keep going until we start being pulled%0A            return leftCoordinate(y, x +1);%0A        else%0A    
     
@@ -1802,32 +1802,86 @@
 nput, _debug);%0A%0A
+        System.out.println(%22rightPointer %22+x+%22 %22+y);%0A%0A
         computer
@@ -2050,16 +2050,52 @@
 ments();
+%0A        boolean beingPulled = true;
 %0A%0A      
@@ -2125,16 +2125,31 @@
 ements()
+ && beingPulled
 )%0A      
@@ -2224,36 +2224,34 @@
 DroneStatus.
-BEING_PULLED
+STATIONARY
 .equals(valu
@@ -2270,26 +2270,41 @@
     
-%7B%0A
     
-    
+beingPulled = false;%0A
         
 x++;
@@ -2303,12 +2303,9 @@
     
-x++;
+%7D
 %0A%0A  
@@ -2314,173 +2314,129 @@
     
-        computer = new Intcode(_input, _debug);%0A%0A                computer.setInputs(%22%22+x, %22%22+y);%0A                computer.executeProgram();%0A            %7D%0A        %7D%0A%0A
+if (beingPulled)  // keep going until we stop being pulled%0A            return rightCoordinate(y, x +1);%0A        else%0A    
     
@@ -2513,16 +2513,61 @@
 _input;%0A
+    private Vector%3CCoordinatePair%3E _theGrid;%0A
     priv

Update Grid.java