advent-of-code/2022/python/day06.py

24 lines
377 B
Python
Raw Normal View History

2022-12-09 16:43:00 +00:00
from shared import load_rows
2022-12-12 07:41:14 +00:00
2022-12-09 16:43:00 +00:00
def part1(row, group_size=4):
for x in range(len(row)):
2022-12-12 07:41:14 +00:00
if len(set(row[x : x + group_size])) == group_size:
print(x + group_size)
2022-12-09 16:43:00 +00:00
break
2022-12-12 07:41:14 +00:00
2022-12-09 16:43:00 +00:00
def part2(row):
part1(row, 14)
2022-12-12 07:41:14 +00:00
2022-12-09 16:43:00 +00:00
def main():
rows = load_rows(6)
for row in rows:
part1(row)
part2(row)
if __name__ == "__main__":
main()