This is true, I just forgot to iterate multiple times for 180/270. Part 1 had been multiplying my rotation by n/90, which obviously isn't quite enough when a transform is needed. Iteration got forgotten, and solved once it got added back in!
I was close to getting my dot-product on, too, but I'm hitting peak puzzle fatigue right now, and just wrote a sloppy solution that thinks in quarter turns.
I ended up solving it by using the idea of a rotation matrix from linalg to be fair and technically used matmul but the matmul is trivial for two dimensions, so a vector transformation solution is good and honestly better than most other solutions which dont necessarily generalize to any possible angle (i.e. not 45,90,180,270,and the others that the test case used)
More interestingly is how the coordinates flip/negate. Rotate left means to flip the coords and flip the E/W positivity. Rotate right means to coords and flip the N/S positivity.
TBH after finishing the puzzle this morning I went and reimplemented my very simple rotate function (which just swapped and negated values) as applying a rotation matrix.
When I was refactoring I made a mistake that wasn't detected by the test input (mixing up east and west); fortunately I didn't do that on my original solution else I'd be tearing my hair out.
And then there are people like me who it wouldn't have helped anyhow.
I carefully wrote my rotation function and tested it, figuring that's where I would make an error in part 2. Woo everything looks great! Run part 2, pass the test example, then get the wrong answer.
It turns out I messed up rotating 180' AND misread my output when I was testing the function...
I don't blame the Advent of Code gang. Some of us just can't be saved.
I spotted that immediately. On paper my code should work, it works with the test case, but doesn't work with my puzzle input. I saw that the test case didn't have any L instruction, so I checked my code under the L case, changed a >= to > and it fixed everything lol.
I'm a bit salty about day 12, too. I found the problem rather simple (just execute the sequence of instructions) but it was very prone to basic mistakes, like swap x and y, forget a minus sign here or there, forget to account for the relative position of the waypoint... It took me so long for so little!
I didn't realize this until several days in my first year of AoC either. I always just thought of the samples as explanations, not something I could actually test against.
I did similar. I had int delta = (direction == SOUTH || direction == EAST) ? -value : value; and spent so long trying to find the bug, before I realized it should have been WEST.
This was me on day 4. My answer kept coming in too high, and I ended up poring over debug output and comparing it to the input file. It all looked right.
Turns out one of my validation checks was wrong, and there was ONE example in the input data where that check lead to a false positive. It was miserable.
My wife passed the age of doing that kinda of thinking. These days, I took a nap till 10:45pm, and then go back to work till 1:00am. I think she trusted me, since I think i can literally do tons of things in those hours. I did tons of things, but only coding :) Not just to write test cases, but mainly get things working.
I'm still stuck on day 11 part one with exactly this scenario— I pass the step-by-step of the supplied test case, and the final result, but my actual solution value is too low. Grr!
This comment deserves more visibility. I admit that I saw this meme and chuckled, not thinking any more of it until I read your comment. And it's a shame how normalized all this is, that it can pass us by without half of us even realising...
This reply deserves more visibility. I admit that I saw this meme and chuckled, and then I read the first reply and got all sad, not thinking any more of it until I read your reply. And it's a shame how much of a rollercoaster all of this is, that it can pass us by without a quarter of us even realising...
59
u/AlbondDev Dec 12 '20
I thought today's test case was a bit useless, especially for the second part. Only 1 rotation, and it's 90°
44
u/solpyro Dec 12 '20
I was today days into the puzzles when I realised I could run the code against the test data >_<
15
u/lamperi- Dec 12 '20
You should move to Europe. No going back to bed after finishing with AoC.
6
u/emu_fake Dec 12 '20
Yeah... i was fuckin stuck with it today...
Test: Everything is fine
Actual puzzle: Uhm, thats a no from me.
Turned out for the 2nd part I had a copypasta bug where for the L rotation I still changed my vector from part 1 instead of the waypoint.
Sadly the example had no L rotation so my unit test couldn't smash it in my face :<
5
u/asdjfsjhfkdjs Dec 12 '20
This was me on day 4. My answer kept coming in too high, and I ended up poring over debug output and comparing it to the input file. It all looked right.
Turns out one of my validation checks was wrong, and there was ONE example in the input data where that check lead to a false positive. It was miserable.
3
u/windmaomao123 Dec 12 '20
My wife passed the age of doing that kinda of thinking. These days, I took a nap till 10:45pm, and then go back to work till 1:00am. I think she trusted me, since I think i can literally do tons of things in those hours. I did tons of things, but only coding :) Not just to write test cases, but mainly get things working.
2
u/DDFoster96 Dec 12 '20
With yesterday's second part I'd get the "correct" answer for the example, but that was a coincidence and the wrong seats were occupied.
3
u/Prudent_Candle Dec 12 '20
That picture implying that I have a girl :P
4
u/GlitteringBeing Dec 12 '20
This picture is implying that I'm a guy. Meh.
1
u/thedjotaku Dec 12 '20
So much so
1
u/edo9k Dec 12 '20
All the time, mate, all the time.
1
u/showherda Dec 13 '20
btw, anyone had angles that are not some multiple of 90 degrees?
1
u/Meltz014 Dec 13 '20
Since we go to bed about the same time the challenge comes out, my situation is more "I could be working on today's challenge right now"
1
u/nlowe_ Dec 13 '20
Had this happen to me twice this year so far! Yesterday and Day 10.
0
u/[deleted] Dec 12 '20
[deleted] — view deleted comment