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.

great filter when

A = char(readlines("input.txt","EmptyLineRule","skip"));
N = [4,14];

I = zeros(1,length(N));
Cond = false(1,length(N));
i = 1;
while all(Cond) && (i+1<=length(A))
    for j = 1:length(N)
        if (Cond(j)) && (length(unique(A(i:i+N(j)-1))) == N(j))
            I(j) = i+N(j)-1;
            Cond(j) = true;
        end
    end
    i = i+1;
end

fprintf("Part 1 : %d\n",I(1))
fprintf("Part 2 : %d\n",I(2))
Jump in the discussion.

No email address required.

@Jinglevann it's me, ya boy

Is markdown shit being active in code blocks a normal thing? Can't use ~ in these then

Jump in the discussion.

No email address required.

fixed king, my apologies

Jump in the discussion.

No email address required.

:#chadthankskingcapy:

Jump in the discussion.

No email address required.

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