import java.util.*;

// network of machines.

public class Network
{
    public static final int NETWORK_SIZE = 50;

    public Network (boolean debug, String fileName)
    {
        _theNetwork = new Intcode[NETWORK_SIZE];
        _debug = debug;

        for (int i = 0; i < NETWORK_SIZE; i++)
            _theNetwork[i] = new Intcode(IntcodeUtil.readValues(fileName), ""+i, debug);
    }

    public final Packet getFirstPacket (long destination)
    {
        Packet toReturn = null;

        do
        {
            for (int i = 0; (i < NETWORK_SIZE) && (toReturn == null); i++)
            {
                _theNetwork[i].executeUntilInput();

                if (_theNetwork[i].waitingForInput())
                {
                    _theNetwork[i].setInput(Packet.EMPTY_PACKET);
                    _theNetwork[i].executeUntilInput();
                }
            
                LinkedList<String> outputs = new LinkedList<String>(_theNetwork[i].getOutputs());

                while (!outputs.isEmpty())
                {
                    Packet thePacket = new Packet(outputs);
                
                    if (_debug)
                        System.out.println("Packet received from computer "+i+" is "+thePacket);

                    if (thePacket.getAddress() == destination)
                        toReturn = thePacket;
                    else
                    {
                        if (thePacket.getAddress() < NETWORK_SIZE)
                            _theNetwork[(int) thePacket.getAddress()].setInputs(""+thePacket.getX(), ""+thePacket.getY());
                    }
                }
            }
        } while (toReturn == null);

        return toReturn;
    }

    private Intcode[] _theNetwork;
    private boolean _debug;
}
@@ -381,24 +381,1351 @@
 ug);%0A    %7D%0A%0A
+    public final Packet getPacket ()%0A    %7B%0A        Packet toReturn = null;%0A        NAT theNAT = new NAT();%0A%0A        do%0A        %7B%0A            for (int i = 0; (i %3C NETWORK_SIZE) && (toReturn == null); i++)%0A            %7B%0A                _theNetwork%5Bi%5D.executeUntilInput();%0A%0A                if (_theNetwork%5Bi%5D.waitingForInput())%0A                %7B%0A                    _theNetwork%5Bi%5D.setInput(Packet.EMPTY_PACKET);%0A                    _theNetwork%5Bi%5D.executeUntilInput();%0A                %7D%0A%0A                LinkedList%3CString%3E outputs = new LinkedList%3CString%3E(_theNetwork%5Bi%5D.getOutputs());%0A%0A                while (!outputs.isEmpty())%0A                %7B%0A                    Packet thePacket = new Packet(outputs);%0A                %0A                    if (_debug)%0A                        System.out.println(%22Packet received from computer %22+i+%22 is %22+thePacket);%0A%0A                    if (thePacket.getAddress() == NAT.ADDRESS)%0A                        theNAT.setPacket(thePacket);%0A                    else%0A                    %7B%0A                        if (thePacket.getAddress() %3C NETWORK_SIZE)%0A                            _theNetwork%5B(int) thePacket.getAddress()%5D.setInputs(%22%22+thePacket.getX(), %22%22+thePacket.getY());%0A                    %7D%0A                %7D%0A            %7D%0A        %7D while (toReturn == null);%0A%0A        return toReturn;%0A    %7D%0A%0A
     public f

Update Network.java