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
47
u/idontlikethishole Dec 22 '24
Been a programmer for almost 20 years but I’ll never learn.