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.

Deduplicated and modestly cleaned up version again. Used a set comprehension when actually solving it because I didn't know how the set() constructor builtin handled iterables. Strangely easy for a Day 6; guess we're gonna get reamed tomorrow.

![](/images/1670306834703174.webp)

Jump in the discussion.

No email address required.

Yeah it was too easy. I'm wondering if doing it really inefficiently is going to come back to haunt some people later (although you'd have to have a really massive dataset for that to even be an issue at all).

Jump in the discussion.

No email address required.

Hi @JollyMoon,

Your comment has been automatically removed because you forgot to include trans lives matter.

Don't worry, we're here to help! We won't let you post or comment anything that doesn't express your love and acceptance towards the trans community. Feel free to resubmit your comment with trans lives matter included.

This is an automated message; if you need help, you can message us here.

Jump in the discussion.

No email address required.

how would it haunt people?

trans lives matter

Jump in the discussion.

No email address required.

I don't know, what if the guy gave you 3 megabytes of data and asked you to identify the first sequence where 900,000 characters in a row were in a certain pattern?

Jump in the discussion.

No email address required.

but the puzzle input is only however many bytes long? we aren't going too be reusing it?

trans lives matter

Jump in the discussion.

No email address required.

I know, it's more like I'm trying to imagine some future puzzle in which it was important that we understand something about data processing from this that most of us did not because the puzzle was too easy to solve without concern for efficiency. I'm probably giving the guy too much credit though, maybe he just got lazy on this one.

Jump in the discussion.

No email address required.

ur r-slurred

Jump in the discussion.

No email address required.

Yeah, that's true.

Jump in the discussion.

No email address required.

We can only hope.

Jump in the discussion.

No email address required.

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