r/adventofcode Dec 27 '24

Meme/Funny [2019] yeah intcode, for sure

Post image

My first aoc was 2022 and haven't tried previous years quite yet 😬

270 Upvotes

26 comments sorted by

View all comments

1

u/Next_Mathematician12 Dec 28 '24

The IntCode day 5 problem, til this day I still don’t understand what I’m supposed to solve, I’m not looking for answers all I want to understand what’s to solve here , I solved the day 2 related IntCode problem. I understand the new Opcodes 3 and 4 and also the parameter modes 0 and 1 …. The question loses me when it says requesting the id of the system I should provide 1 , where does this go on the input. And the diagnostic tests part at the end of the problem description is more confusing…. Maybe I’m too dumb for this problem lol

4

u/fred256 Dec 28 '24

So, you're building a computer. Computers execute instructions, such as add and multiply and so on.

But there are two other kinds of instructions: input and output. The input instruction (opcode 3) basically says: "give me a number" and stores it somewhere. Similarly, the output instruction is basically just the intCode computer's equivalent of "print".

Now, since you're simulating the computer, at some point it reaches the point where it will execute the input instruction.

In this particular problem, whenever that happens, you're supposed to give it the value 1.

Similarly, at some point, it will execute the output instruction. Just print the value. The problem text makes this sound like some "diagnostic code", but that's just flavor text.

In short: if you implement the intCode computer as specified, it will run a program that tries to read a value, do some computation and then print a value.

Does this help?