public string SolveB() { var lines = File.ReadAllLines(Input, Encoding.UTF8); var program = Intcode.ParseInput(lines[0]); var computerBank = new Computer[50]; const int numComputers = 50; var nat = new Nat(); long lastY = -666; long?answer = null; Action <PacketToSend> packetSender = (PacketToSend packet) => { if (packet.Destination == 255) { nat.Receive(packet.ToSend); // Is anything processing? bool idle = computerBank.All(c => c.Idle); if (idle) { if (lastY == nat.current.Y) { answer = lastY; } else { lastY = nat.current.Y; } computerBank[0].QueuePacket(nat.current); } } else { computerBank[packet.Destination].QueuePacket(packet.ToSend); } }; for (int i = 0; i < numComputers; i++) { computerBank[i] = new Computer(i, program, packetSender); } while (!answer.HasValue) { foreach (var computer in computerBank) { computer.Step(); } } return(answer.Value.ToString()); }