was preparing my butthole after the last one but ended up being the fastest one i've done
with open("day6input.txt") as f:
input = f.read()
# part 1
for i in range(len(input)):
marker = set(input[i:i+4])
if len(marker) == 4:
answer = i + 4
break
print(answer)
# part 2
for i in range(len(input)):
marker = set(input[i:i+14])
if len(marker) == 14:
answer = i + 14
break
print(answer)
Jump in the discussion.
No email address required.
PLEASE HELP :(
Idk what's wrong with my code. It gave the correct answer for 4 consecutive characters but for 14 it just goes through the entire string without finding a match. I ended up running the solutions for 13 consecutive characters, 12 consecutive chars, etc and noticed that the answers were always incremented:
3: 1099
4:1100
5:1101
6:1107
7:1108
8:1154
9:1155
10:1321
11:1322
12:2419
13:2420
So I just guessed 2421 for 14 and it was right... It's weird because I tried the test inputs and got the correct answer for them all except for![:#marseygiveup: :#marseygiveup:](/e/marseygiveup.webp)
mjqjpqmgbljsphdztnvjfqwrcgsmlb
. Apparently the answer is supposed to be 19 but that makes no sense to me because the 19th character is j and there is also a j for the 10th character. Maybe I am fundamentally misunderstanding the problem. Either way I give upJump in the discussion.
No email address required.
You count forwards from the 19th character, not backwards.
Jump in the discussion.
No email address required.
There are only 30 characters though
Jump in the discussion.
No email address required.
It's weird that he doesn't explain that.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
You sat down and wrote all this shit. You could have done so many other things with your life. What happened to your life that made you decide writing novels of bullshit here was the best option?
Jump in the discussion.
No email address required.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
It's not that nothing in the buffer equals the first character in the buffer. It's that there are not two equal characters in the rolling buffer.
Jump in the discussion.
No email address required.
Yes
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context