Created
December 8, 2022 17:17
-
-
Save eduardoklosowski/64cdc29f86b028bf3cbf1d522b67ffe6 to your computer and use it in GitHub Desktop.
Advent of Code 2022 - Dia 06
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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