aoc-2019-c

Advent of Code 2019 Solutions in C
git clone https://git.sinitax.com/sinitax/aoc-2019-c
Log | Files | Refs | README | sfeed.txt

part1 (2423B)


      1--- Day 23: Category Six ---
      2
      3The droids have finished repairing as much of the ship as they can.  Their report indicates that
      4this was a Category 6 disaster - not because it was that bad, but because it destroyed the stockpile
      5of Category 6 network cables as well as most of the ship's network infrastructure.
      6
      7You'll need to rebuild the network from scratch.
      8
      9The computers on the network are standard Intcode computers that communicate by sending
     10packets to each other.  There are 50 of them in total, each running a copy of the same
     11Network Interface Controller (NIC) software (your puzzle input). The computers have network
     12addresses 0 through 49; when each computer boots up, it will request its network address via a
     13single input instruction. Be sure to give each computer a unique network address.
     14
     15Once a computer has received its network address, it will begin doing work and communicating over
     16the network by sending and receiving packets. All packets contain two values named X and Y. Packets
     17sent to a computer are queued by the recipient and read in the order they are received.
     18
     19To send a packet to another computer, the NIC will use three output instructions that provide the
     20destination address of the packet followed by its X and Y values.  For example, three output
     21instructions that provide the values 10, 20, 30 would send a packet with X=20 and Y=30 to the
     22computer with address 10.
     23
     24To receive a packet from another computer, the NIC will use an input instruction.  If the incoming
     25packet queue is empty, provide -1.  Otherwise, provide the X value of the next packet; the computer
     26will then use a second input instruction to receive the Y value for the same packet.  Once both
     27values of the packet are read in this way, the packet is removed from the queue.
     28
     29Note that these input and output instructions never block. Specifically, output instructions do not
     30wait for the sent packet to be received - the computer might send multiple packets before receiving
     31any. Similarly, input instructions do not wait for a packet to arrive - if no packet is waiting,
     32input instructions should receive -1.
     33
     34Boot up all 50 computers and attach them to your network.  What is the Y value of the first packet
     35sent to address 255?
     36
     37