1
0
Fork 0
adventofcode/2022/06/main.py
2024-12-11 19:23:03 +01:00

35 lines
856 B
Python

#!/usr/bin/env python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# Author: Sebastian Mark
# CC-BY-SA (https://creativecommons.org/licenses/by-sa/4.0/deed.de)
# pylint: disable=missing-module-docstring,missing-function-docstring,consider-using-f-string
def readinput():
with open("input", "r", encoding="utf-8") as file:
lines = file.read().strip()
return lines
def main():
datastream = readinput()
# part 1
for i in range(len(datastream) - 4):
uniq = set(datastream[i : i + 4])
if len(uniq) == 4:
print("Frist marker at %d" % (i + 4))
break
# part 2
for i in range(len(datastream) - 14):
uniq = set(datastream[i : i + 14])
if len(uniq) == 14:
print("Frist marker at %d" % (i + 14))
break
if __name__ == "__main__":
main()