Me either.
I got the sample printing to a grid so I can visualize it, but I don’t know how to fix it. That’s it for tonight.
The worst part is that I had part 2 right for the test data, but now that I’ve “fixed” my code as I understand it, even the test data doesn’t get it right any more
I finally got it right. My “fix” approach for part 2 was going in the wrong direction (and I still don’t understand why), but then I finally revisited the initial code and made a small change and now it looks right and works right. (download project)
Ugh, 1:15 hours
BTW, anyone else accidentally using the first test input for the second part and didn’t realize until minutes later?
Ah, Kem didn’t give up, after all! Good night now!
Just checking my personal stats…
The one where I scored best (1534 for first part) was actually the one where I had the most experience with: Day 7 with the directory scanning. Well, at least that proves that familiarity helps
This was a case where I simply didn’t understand the directions as given. Someone had to explain the motion to me, and then it was easy.
And since it had to be explained to me…
Day 9 Spoiler
Move the head as directed, then go down the line and see if each knot is touching the one before it. If it is, leave it alone. If it it’s not, move it on both the X and Y planes until they are touching.
So if diffX = 2 and diffY = 1, you should end up with diffX = 1 and diffY = 0.
My mistake was in moving the trailing knot until it touched, so I would get diffX = 1 and diffY = 1. In other words, I was moving it on one plane at a time until they touched, but it must move diagonally.
This was one time when the instructions were more useful than the example. I finally made my code plot a map after each move so that I could compare to the example, and was finally able to debug.
I had a different issue:
Spoiler - giving a hint on a special case
I ran into the case where the knots were 2 apart on both axes. I thought that that meant I had made a mistake in a previous iteration. But it turned out that it was a valid case and I hadn’t handle it, yet. I only realized that after re-reading the two rules at the start of the first example.
Wait – it took me 2:15, not 1:15! Damn. And Kem was very close behind me.
I have plans over the weekend so I expect the next time I’ll be working on these will be Sunday night at the earliest.
Since I went to all the trouble of adding a grid plot routine so that I could debug the code, I feel the need to do something with it, so here is the example data for part 2 plotted:
Summary
R 5
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . 5 4 3 2 1 H . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
U 8
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . H . . . . . . . . .
. . . . . . . . . . . . . . . . 1 . . . . . . . . .
. . . . . . . . . . . . . . . . 2 . . . . . . . . .
. . . . . . . . . . . . . . . . 3 . . . . . . . . .
. . . . . . . . . . . . . . . 5 4 . . . . . . . . .
. . . . . . . . . . . . . . 6 . . . . . . . . . . .
. . . . . . . . . . . . . 7 . . . . . . . . . . . .
. . . . . . . . . . . . 8 . . . . . . . . . . . . .
. . . . . . . . . . . 9 . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
L 8
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . H 1 2 3 4 . . . . . . . . . . . . .
. . . . . . . . . . . . 5 . . . . . . . . . . . . .
. . . . . . . . . . . . 6 . . . . . . . . . . . . .
. . . . . . . . . . . . 7 . . . . . . . . . . . . .
. . . . . . . . . . . . 8 . . . . . . . . . . . . .
. . . . . . . . . . . . 9 . . . . . . . . . . . . .
. . . . . . . . . . . . . # . . . . . . . . . . . .
. . . . . . . . . . . . # . . . . . . . . . . . . .
. . . . . . . . . . . # . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
D 3
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . 2 3 4 5 . . . . . . . . . . . . .
. . . . . . . . 1 . . . 6 . . . . . . . . . . . . .
. . . . . . . . H . . . 7 . . . . . . . . . . . . .
. . . . . . . . . . . . 8 . . . . . . . . . . . . .
. . . . . . . . . . . . 9 . . . . . . . . . . . . .
. . . . . . . . . . . . . # . . . . . . . . . . . .
. . . . . . . . . . . . # . . . . . . . . . . . . .
. . . . . . . . . . . # . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
R 17
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . # # 9 8 7 6 5 4 3 2 1 H
. . . . . . . . . . . . . # . . . . . . . . . . . .
. . . . . . . . . . . . # . . . . . . . . . . . . .
. . . . . . . . . . . . . # . . . . . . . . . . . .
. . . . . . . . . . . . # . . . . . . . . . . . . .
. . . . . . . . . . . # . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
D 10
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . # # # . . . . . . . . .
. . . . . . . . . . . . . # . . . # . . . . . . . .
. . . . . . . . . . . . # . . . . . # . . . . . . .
. . . . . . . . . . . . . # . . . . . # . . . . . .
. . . . . . . . . . . . # . . . . . . . # . . . . .
. . . . . . . . . . . # . . . . . . . . . 9 8 7 6 5
. . . . . . . . . . . . . . . . . . . . . . . . . 4
. . . . . . . . . . . . . . . . . . . . . . . . . 3
. . . . . . . . . . . . . . . . . . . . . . . . . 2
. . . . . . . . . . . . . . . . . . . . . . . . . 1
. . . . . . . . . . . . . . . . . . . . . . . . . H
L 25
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . # # # . . . . . . . . .
. . . . . . . . . . . . . # . . . # . . . . . . . .
. . . . . . . . . . . . # . . . . . # . . . . . . .
. . . . . . . . . . . . . # . . . . . # . . . . . .
. . . . . . . . . . . . # . . . . . . . # . . . . .
. . . . . . . . . . . # . . . . . . . . . # . . . .
. . . . . . . . . . . . . . . . . . . . # . . . . .
. . . . . . . . . . . . . . . . . . . # . . . . . .
. . . . . . . . . . . . . . . . . . # . . . . . . .
. . . . . . . . . . . . . . . . . # . . . . . . . .
H 1 2 3 4 5 6 7 8 9 # # # # # # # . . . . . . . . .
U 20
H . . . . . . . . . . . . . . . . . . . . . . . . .
1 . . . . . . . . . . . . . . . . . . . . . . . . .
2 . . . . . . . . . . . . . . . . . . . . . . . . .
3 . . . . . . . . . . . . . . . . . . . . . . . . .
4 . . . . . . . . . . . . . . . . . . . . . . . . .
5 . . . . . . . . . . . . . . . . . . . . . . . . .
6 . . . . . . . . . . . . . . . . . . . . . . . . .
7 . . . . . . . . . . . . . . . . . . . . . . . . .
8 . . . . . . . . . . . . . . . . . . . . . . . . .
9 . . . . . . . . . . . . . . . . . . . . . . . . .
# . . . . . . . . . . . . . # # # . . . . . . . . .
# . . . . . . . . . . . . # . . . # . . . . . . . .
. # . . . . . . . . . . # . . . . . # . . . . . . .
. . # . . . . . . . . . . # . . . . . # . . . . . .
. . . # . . . . . . . . # . . . . . . . # . . . . .
. . . . # . . . . . . # . . . . . . . . . # . . . .
. . . . . # . . . . . . . . . . . . . . # . . . . .
. . . . . . # . . . . . . . . . . . . # . . . . . .
. . . . . . . # . . . . . . . . . . # . . . . . . .
. . . . . . . . # . . . . . . . . # . . . . . . . .
. . . . . . . . . # # # # # # # # . . . . . . . . .
Part 2 example data solution: 36
.
.
.
Great! That gives the rest of us a chance to catch up.
Phew!, it’s starting to get tricky
Weird. I’ve only done up to and including day 2. I’m currently trying to implement switch statements in ObjoScript.
Sorry, had confused you with Robert.
Because I’m insane, I refactored day 9 around a single Solve function, and improved my optional printout to match the web site illustrations.
When I did my Part 2 solution, and replaced the single variables with arrays to track the knot positions, it was inherently able to do ropes with any number of knots, including the part 1 problem. So, I deleted the part 1 code.
However, I did go back and replace the big grid array with a dictionary to track the positions travelled. I found the grid array made it easier to debug, but a rather inefficient way to do it. My currently uploaded version now has both the grid array and the dictionary versions.
I initially also thought about using a 2-dim array but soon realized that it would be a pain to shift it if the moves went into negative coords. So I used a Dictionary (Set) from the start, with the key being x + y*1000.
I also ended up with a single solve function, but that only came out after solving part 2.
Oh, Kem used the Xojo’s Point class. Why didn’t I think of that?!
And there’s a Point.ToKey method?? Or did you add that to your support functions, @Kem_Tekinay? Ho does it calc the key?
Not sure if I’m gonna get up for Day 10 in less that 5 hours. This is your chance for a gold start, Robert!
I hadn’t thought of the point class either. I initially tried using the pair class, which it accepted, but didn’t give correct results. So, I ended up concatenating the coordinates into a single string value.
That’s a function I added today. It uses a default range that can be given as a parameter. Not perfect, but I think it will work here.
OSS BASIC XE (well XL) was one heck of a lot better than the Atari Basic that came with my machine!
(I owned the OSS BASIC XL and Action! cartridges … i tossed out my working Atari 800 and those cartridges around a decade or so ago!)
-Karen
Today’s wasn’t too tough. And now I can sleep (somehow).
I’ve just read the part one, it sounds a little bit to what we had to do in 2019. Maybe we’ll end up building another VM?