Skip to content

Instantly share code, notes, and snippets.

@eduardoklosowski
Created December 8, 2022 17:17
Show Gist options
  • Save eduardoklosowski/64cdc29f86b028bf3cbf1d522b67ffe6 to your computer and use it in GitHub Desktop.
Save eduardoklosowski/64cdc29f86b028bf3cbf1d522b67ffe6 to your computer and use it in GitHub Desktop.
Advent of Code 2022 - Dia 06
window = 14
for line in open(0):
chars = [-1 for _ in range(256)]
equal = -1
for i, c in enumerate(ord(c) for c in line):
if chars[c] > equal:
equal = chars[c]
else:
if i - equal == window:
print(i + 1)
break
chars[c] = i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment