Review the Solution
The first line, we start a loop, and what we’re doing here is that we’re just looping over indices that run from
marker_length, which means that essentially we start looking at the first, say, four-character marker in part one of the puzzle.
Then on what’s line 7 there, we pick out the candidate that we want to check to see if it’s a marker. So we do this just by slicing into the stream based on the
n number that we’re looping over.
00:49 And then we’re doing the check on the candidate. And we had this insight where we figured out that one way to check if there are repeated letters in a candidate is just by converting it to a set because that operation removes duplicates.
And if anything has been removed, then the length of the set will be different from the marker length. So in that case, it’s not the marker. If the length is equal to the marker length, that means that we have found a marker, and we can stop looping, and we stop looping here by having a
Become a Member to join the conversation.