[2018 Day 16 (Part 1)] Troubleshooting

Help

I have an implementation for part 1, for which the only example given passes. My program output of ~620 is apparently too high. I submitted a somwhat random value of 560 (just to see if I was in the ballpark) which was too low, so I'm not that far off.

However, I don't get how I can do any kind of troubleshooting. As far as I can tell, my implementation can be incorrect for any of the 16 opcodes. Apart from staring at the code, what can I do?

Posted Dec 16, 2018, 6:43 PM UTC

18
vt_bear•

Post your code so we can give you a hint

1
kroppeb•

My bet would be that you implemented one of the ops wrong. You might have made a mistake with value vs register with one of them, but we'd need to see your code to be sure

1
FogLander•

I had the same issue and I had made some dumb mistakes in my op implementations. Make sure you're fetching from and asssigning to the right registers!

1
ephemient•

For what it's worth, here's my input and debug trace: https://pastebin.com/7JRYdDif

1
LeCrushinator•

I can't get past part 1. The example input it gave me worked as expected. But when I run all of the samples my input against all 16 opcodes, the number of results that behave like 3 or more opcodes isn't correct.

So I took your debug trace and read that in as a type of input, and it took the registers from 0,0,0,0 all the way to 481, 481, 3, 0 using your trace data. I'm 99% confident that all of my opcodes work, so I'm baffled.

1
Imsdal2OP•

I specifically didn't include my code, as I didn't want someone to point out the error. Instead, I wanted suggestions on how to find what could be wrong.

For others who may be in the same boat, here are a few things to test:

  1. Run each sample for each opcode, and verify that they have different number of correct answers. (You may be unlucky with your input data, so that two opcodes may have the same number of correct mappings.)
  2. Verify that your output only ever modifies one single registry. (This is how I found my issue.)
1
madacoo•

Also, since this is how I solved a bug that took me an hour to find, verify that each sample matches at least one opcode.

1
CCC_037•

Did you initialise your registers correctly?

0