Solve 2022 day 6 pt 1-2
This commit is contained in:
parent
e800a005e8
commit
a708d791c2
1 changed files with 21 additions and 0 deletions
21
2022-python/output/day_06.py
Normal file
21
2022-python/output/day_06.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
def solve(data):
|
||||
for p1 in range(4, len(data)):
|
||||
if len(set(data[p1 - 4 : p1])) == 4:
|
||||
break
|
||||
for p2 in range(14, len(data)):
|
||||
if len(set(data[p2 - 14 : p2])) == 14:
|
||||
break
|
||||
return p1, p2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open("./input/06.txt", "r") as f:
|
||||
inp = f.read().strip()
|
||||
|
||||
p1, p2 = solve(inp)
|
||||
|
||||
print(p1)
|
||||
print(p2)
|
||||
|
||||
assert p1 == 1238
|
||||
assert p2 == 3037
|
||||
Loading…
Add table
Reference in a new issue