Advent of Code 2019 Day 23
Task: Solve for X where...
Part 1
X = the Y value of the first packet sent to address 255
No example input given
The only example offered is this:
For example, three output instructions that provide the values 10, 20, 30 would send a packet with X=20 and Y=30 to the computer with address 10.
Part 1
- Intcode computer: Round 11!
- Trying to understand each rule
- Running the program for clues
- Browsing the Reddit Solution Megathread for help
- This puzzle is out of my reach
Intcode computer: Round 11!
This task feels daunting:
You'll need to rebuild the network from scratch.
This puzzle feels similar to Day 7 where multiple computers and programs run simultaneously, generating output and passing input between one another
Trying to understand each rule
Computers communicate by sending packets to each other
There are 50 of them in total, each running a copy of the same Network Interface Controller (NIC) software
- I'll need to track the state of several computers and as many program's input and output
The computers have network addresses 0 through 49; when each computer boots up, it will request its network address via a single input instruction. Be sure to give each computer a unique network address.
- Wait. So I get to choose the network address? Or I should choose the numbers 0-49?
- And will I need to queue that address as the initial value of some input variable for each program?
- Hopefully this will all become clear...either in the instructions or through trial and error
Once a computer has received its network address, it will begin doing work and communicating over the network by sending and receiving packets.
- Point 1 above remains unanswered
- Point 2 seems answered: Yes, the initial input value should be the assigned network address
All packets contain two values named X and Y
- So, I'll need to track more than a single initial input value. Thus, an ordered list of values.
Packets sent to a computer are queued by the recipient and read in the order they are received.
- So, further complexity in how and when those ordered list of packet values per program are populated
Sending and receiving packets
To send a packet to another computer, the NIC will use three output instructions that provide the destination address of the packet followed by its X and Y values.
- A program will eventually generate three values as output
- Maybe Point 1 way above is answered: the programs will dictate the addresses
To receive a packet from another computer, the NIC will use an input instruction.
- Hmm. So a minimum of one value is usable by any computer. Not all three.
If the incoming packet queue is empty, provide -1. Otherwise, provide the X value of the next packet.
- Wow. So I need a condition to check the values in each program's output.
- I'm confused by
next
packet. Where is the order coming in to play?
The computer will then use a second input instruction to receive the Y value for the same packet
- X value of next packet, but Y value for same packet? Huh?
Once both values of the packet are read in this way, the packet is removed from the queue.
- Yikes. I have to manage a queue of packets containing accumulating amounts of values.
Output instructions do not wait for the sent packet to be received - the computer might send multiple packets before receiving any
- So, the queue will ebb and flow in size, with one computer being active for a while, potentially
Input instructions do not wait for a packet to arrive - if no packet is waiting, input instructions should receive -1
- This references the condition introduced above
- At this point, I'm pretty darn confused
What is the Y value of the first packet sent to address 255?
- Here is the task, again
- It implies that one computer will have
address
255 - Is that the same as a
network address
? - That's not a number between 0 and 49
- So, why even mention that range of network address numbers?
Running the program for clues
Using an input of 0
- And running one copy of the program
- It seemingly funs forever
- So when capped at 20 instructions processes
- And displaying only the values stored as input
- It shows three integers:
62, 64, 65
- Upping the cap to 200:
62, 64, 65, 64, 65, 64, 65, ...
Using an input of -1
- The program throws an error, I believe because it is trying to process an opcode of 10
I'm genuinely confused.
Browsing the Reddit Solution Megathread for help
- There's mention of multi-threaded algorithms, asynchronous algorithms, multiple lists of 50 things to track all the things, avoiding race conditions and non-blocking I/O
- All of that only adds to my confusion, and lessens my interest in attempting to solve this puzzle
This puzzle is out of my reach
That's a bummer because it's now the second Intcode computer puzzle where I failed to solve Part 1.
I'm still hopeful that I can solve Day 25 Part 1, because I solved Days 9 and 17, and therefore have a complete ASCII-capable Intcode computer.
I just hope I can program it to solve the last day's puzzle.
But first, one last non-Intcode computer puzzle in this year...coming up!
Top comments (0)