Behold: The Twist
00:00 If you were a little bit scratching your head with the solution that Geir Arne was doing so far, coming like maybe more from a programmer’s mindset where you’re thinking like, okay, that seems very hard-coded what you’re doing there with first, second, and third.
00:15 What if some parameter would change? Then you were exactly right because part two wants you to elevate your code a little bit. So let’s see if the code that you wrote so far, Geir Arne, holds up to this new challenge.
00:41 It seems like we also need to look for messages, and apparently these start-of-message markers, they work just like the start-of-packet markers, except that they are looking for fourteen distinct characters rather than four.
Then it kind of repeats the same examples that we had in the previous one and says, for instance, this
mjqj stream that we were working with in the beginning, the first message marker comes at character
The logic that we used here is sound. We can definitely continue the logic, but I think this approach is kind of not very scalable because what I would now need to do here to also handle fourteen would be that I’m starting doing
seventh, and so on.
01:53 But I would then also need to look for all of these combinations, and that would be close to a hundred combinations or something like this. So we should rethink a little bit how we’re working with this. Instead of directly working with part two, I’m going to redo part one in a more efficient manner, so to speak, where we can use the number four more like a parameter than something that we hard-code into the code here.
02:17 Yeah, it’s a good idea to not jump into part two right away and come up with a new solution that works for part two, but to take a step back and say, like, the first approach doesn’t work for part two, but coming up with a new approach that works for part one and for part two.
Become a Member to join the conversation.