https://kotlinlang.org logo
#advent-of-code
Title
# advent-of-code
d

Davio

12/08/2023, 8:56 AM
Advent of Code 2023 day 8 NO SOLUTIONS 🧵
I'm curious to know if I misunderstand something about this puzzle: are you supposed to follow the entire list of directions fully each time (so if it's RLR always do RLR, then check), or are you also supposed to check after each single step if you are finished (for part 2)?
p

phldavies

12/08/2023, 8:59 AM
Each R or L moves you to a new node, it's on each node that you check.
n

nvbahool

12/08/2023, 9:11 AM
It is not mentioned in the task, but it seems that you cannot finish unless you followed the entire path one or multiple times
s

Sergei Petunin

12/08/2023, 9:27 AM
At first I implemented the check for each step of the path, but then it turned out that (at least for my input) the termination node is always at the end of the path.
d

Davio

12/08/2023, 9:29 AM
Yeah that is kind of my suspicion so I'm not sure if it's a coincidence or intended
m

Michael Böiers

12/08/2023, 9:33 AM
The puzzle wording suggests to check after each step, so why would anyone even begin to think that it is not necessary?
s

Sergei Petunin

12/08/2023, 9:34 AM
Well, it says
repeat the whole sequence of instructions
, which I understood as you always need to run the set of instructions till the end, maybe multiple times.
😮 3
d

Davio

12/08/2023, 9:34 AM
That, and each of the examples have it so it completes after having performed the entire sequence of steps
n

nvbahool

12/08/2023, 9:39 AM
Oh, it really does mention “repeat the whole sequence of instructions”. That was easy to miss
p

phldavies

12/08/2023, 9:52 AM
I took that to mean "if you run out of instructions before reaching the end, then repeat them"
d

Davio

12/08/2023, 10:57 AM
I wonder at what order of magnitude I can expect for part 2, is it in the millions, billions, or ...?
s

Sergei Petunin

12/08/2023, 10:58 AM
Around 10^13 for me.
d

Davio

12/08/2023, 10:58 AM
😧
My (not yet validated) assumption is that there will be cycles and that I'm to use the least common multiple of the lengths of these cycles, but not sure if it's correct and how to implement it, but I'll think on it a bit more
🤞 3
a

Andreu

12/08/2023, 11:09 AM
I hope that's not too much of a spoiler but the input does have some properties that are not mentioned in the problem description
k

kqr

12/08/2023, 11:12 AM
Copy code
Of course, you might not find ZZZ right away. If you run out of left/right instructions, repeat the whole sequence of instructions as necessary: RL really means RLRLRLRLRLRLRLRL... and so on.
as neccessary
n

nvbahool

12/08/2023, 11:21 AM
“repeat the whole sequence *as necessary*” can be interpreted in at least two different ways. But it seems that this wording implies that the sequence should be repeated in it’s entirety as many times as needed
k

kqr

12/08/2023, 11:26 AM
hm, right. but still to run out of instructions I understood that I am consuming them by one
d

Davio

12/08/2023, 11:54 AM
Okay I finally solved it, I'll head over to the other thread 😄
🎉 3
e

evgenim

12/08/2023, 8:41 PM
I asked ChatGPT today if there is a Greatest Common Divisor function in Kotlin standard library, it said kotlin.math.gcd. And it started to make excuses after
n

Neil Banman

12/09/2023, 4:33 AM
I’ve been using a bit of chatGPT to help me when I inevitably make a wrong turn in Rust. Overall it’s pretty impressive, but yeah sometimes it makes stuff up.
6 Views