This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
Total honesty, I had to read through the instructions A LOT, once again, to understand what was going on here.
We're back to Intcode, but with a few more wrinkles. Part 1 involves two new instructions (opcode 4 which is a simple output command, and opcode 3 which writes a new value into a specified location). Plus there are now 2 modes for the parameters, position (which is what we worked with on day 2) and immediate (just use the number that's there)
I'm able to tweak my original Intcode macro to work with these new requirements with minimal work.
Onto part 2. I'm stubborn, and assume that I can continue to modify my Intcode macro to include the 4 new opcodes, two of which change the values in the string, and two of which change the pointer. After many failed attempts, I finally get the logic to work. Verify it with a Debug mode, and guess what? It fails. I mean completely fails. What ran 105 iterations perfectly now won't run more than 1, and won't output a darn thing.
It's a really ugly scene. I know, I wanted to make something more flexible, but it didn't work out. And I NEVER want to modify this again:
**balls up existing Intcode macro and starts from scratch***
Luckily for me, @patrick_digan had suggested an approach a few days ago that works like a dream, and took about 10 minutes to fully design and think through. The key is making all of the numbers the same length, instead of trying to figure out how many commas to space out on (that doesn't work at all) before running the macro.
So much smoother. So much faster. Thank you, Digan. I'm no longer dreading further Intcode challenges (although when the next one comes down the pike I may revoke that last statement)
Whew, I don't know if I'm ready to re-live the nightmare that was Day 5!
It took me many, many stabs in the dark to figure out what we were being asked to do on this one. Now that I look back on the instructions, I'm not sure exactly what I missed, but boy did I have to experiment with a lot of different assumptions before coming up with the correct answer.
First, my brittle intcode from Day 3 expected four elements (and on day 5, we add commands that only have two), so I had to fix that.
Next, for part 2, I had to figure out how to move the pointer a variable number of spaces.
Trying and failing several times resulted in a gigantic, inefficient macro :
After finally, finally, finishing Day 5 part 2, I took a look at @patrick_digan's solution. I had considered string parsing, but really wanted to avoid it for readability/debugging reasons. I decided to keep going with my current solution because, well, it does work! Maybe I can just streamline it for the next intcode challenge (foreshadowing for day 7)...