Files
advent-of-code/2025/day05/part1.py
2025-12-05 11:24:04 +03:00

44 lines
995 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

range_list: list[str] = ["1-5","7-8"]
items_list: list[int] = [1,2,3,6,16]
valid_id: list[int] = []
input = """3-5
10-14
16-20
12-18
1
5
8
11
17
32"""
input = """515109478873629-517495683097941
55910578479451-59894189259887
388889831860114-389361546156805
426667061525753-431247335780190
163539375204061
531903863069312
34101977519160
164401920447043
5765415079155
235541805889895
241438782449974
228538610394597
557824039518207"""
# with open("input.txt", "r") as file:
# input = file.read()
range_list = list(map(str, input.split("\n\n")[0].strip().split("\n")))
items_list = list(map(int, input.split("\n\n")[1].strip().split("\n")))
# получаем все возможные не "протухшие" id продуктов
for element in range_list:
valid_id += [i for i in range(int(element.split("-")[0]),int(element.split("-")[1])+1)]
# valid_id_set = list(set(valid_id))
print(valid_id)
print("Всего найденно",len(set(valid_id) & set(items_list)))