Unable to load image

Advent of Code day 6

was preparing my butthole after the last one but ended up being the fastest one i've done :marseyexcited:

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)
28
Jump in the discussion.

No email address required.

k = 14
file = open("input.txt")
c=file.read(k-1)
i = k-1
while True:
    c+= file.read(1)
    i+=1
    if(len(set(c[-k:]))) == k: break;
print(i)

No part1/2 because all i had to do is change one variable. They must be being generous before the big ones

Jump in the discussion.

No email address required.



Now playing: Da Banana Bunch (DK64).mp3

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.