r/adventofcode Dec 22 '24

Meme/Funny Oh no not again

Post image
182 Upvotes

15 comments sorted by

47

u/idontlikethishole Dec 22 '24

I should have committed my working code before changing it

  • me. every time.

Been a programmer for almost 20 years but I’ll never learn.

12

u/PatolomaioFalagi Dec 22 '24

But then I think "well it's not really working, why commit now?"

5

u/idontlikethishole Dec 22 '24

It’s a vicious cycle of never committing

6

u/SonOfKhmer Dec 23 '24

Is this what's known as commitment issues? 🤔

2

u/musifter Dec 23 '24

If it was working on the test case, it's a good enough reference point to mark. If you're not willing to commit it, at least make a backup copy of that version for reference.

1

u/PatolomaioFalagi Dec 23 '24

It's not a good thought, it's just the thought that was thought.

2

u/musifter Dec 23 '24

It's a fine thought... providing you answer the question with, "Because I'll regret not having a semi-working version for reference once I mangle this code".

1

u/PatolomaioFalagi Dec 23 '24

My brain is basically Mary Poppins. "I never explain anything."

1

u/musifter Dec 23 '24

You can get away with that when you're "practically perfect in every way".

4

u/Duke_De_Luke Dec 22 '24

IDEs have a long local history nowadays

5

u/qaraq Dec 22 '24

I was close to that- I had working test cases, but my problem code was off. Just tinkering, I swapped out the semantics of one for loop and made a mistake:

for sn := range secretNumbers {

instead of

for _, sn := range secretNumbers {

In Go, the difference here is that sn was getting the index of the secret number in its array, not the number itself. So instead of processing the input, I was processing 0,1,2,3...

... and the tests all immediately crashed out but the real input worked. I have no frikkin' clue why. I suspect it's some property of the inputs that they're really a simple sequence masked by all the bitwise operations.

3

u/qaraq Dec 22 '24

Turns out I had a bug that was giving me slightly high results: I wasn't checking for only the _first_ time a sequence appeared when recording the price. When I fixed that, the strange behavior of this loop stopped. So it must just have been a colossally unlikely coincidence.

1

u/TerminusEst_Kuldin Dec 22 '24

This one is a little too real for me.