add 2022/day06
This commit is contained in:
parent
c2b5593a6c
commit
5b87ed8692
1 changed files with 35 additions and 0 deletions
35
2022/06/main.py
Normal file
35
2022/06/main.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#!/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()
|
Loading…
Reference in a new issue