From ec30800900e336782fce6c50bc8411ec9a7b1fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B9=20=D0=A7=D0=B5=D1=80=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=BA=D0=BE?= Date: Fri, 5 Dec 2025 15:41:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2025/day05/part2.py | 73 ++++++++++++++++++++++++++++++++++ 2025/day05/txt.csv | 96 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 2025/day05/txt.csv diff --git a/2025/day05/part2.py b/2025/day05/part2.py index e69de29..cf83668 100644 --- a/2025/day05/part2.py +++ b/2025/day05/part2.py @@ -0,0 +1,73 @@ +range_list: list[list:[str]] = [['1','5'],['7','8']] +items_list: list[int] = [1,2,3,6,16] +valid_id: list[int] = [] +final_range: list[list:[int]] = [[0,0]] + +input = """3-6 +5-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(list, [row.split("-") for row in input.split("\n\n")[0].strip().split("\n")])) +items_list = list(map(int, input.split("\n\n")[1].strip().split("\n"))) +# получаем все возможные не "протухшие" id продуктов +# for index,i in enumerate(items_list): +# for element in range_list: +# if i >= int(element[0]) and i <= int(element[1]): +# valid_id.append(i) +low_list, high_list = [], [] +for item in range_list: + low_list.append(int(item[0])) + high_list.append(int(item[1])) + +range_new_dict: dict[int:int] = {} +for low,high in zip(low_list, high_list): + range_new_dict[int(high)] = int(low) +high_list = sorted(high_list, reverse=True) +final_range = [[0,high_list[0]]] +for d in high_list: + + if d >= final_range[-1][0] and d != range_new_dict[d]: + final_range[-1][0]= range_new_dict[d] + final_range[-1][1]= final_range[-1][1] + print("занесли изменения") + # elif d == range_new_dict[d] and final_range[-1][1] < d: + if d > final_range[-1][0] and d == range_new_dict[d]: + print("pass!!!") + pass + else: + print("bang!") + final_range.append([range_new_dict[d],d]) +result: int = 0 +for item in final_range: + print(item) + result += item[1] - item[0] + 1 + # print(result) + +print("result",result) +# print("Всего найденно",len(set(valid_id))) \ No newline at end of file diff --git a/2025/day05/txt.csv b/2025/day05/txt.csv new file mode 100644 index 0000000..ed583ff --- /dev/null +++ b/2025/day05/txt.csv @@ -0,0 +1,96 @@ +555833573705560,559215810479919 +544342752994236,549627382712867 +537510887695323,541274271491753 +526877848613335,531769418916012 +512913115187844,522212556489529 +511011466557299,512131793619361 +510842576934065,511011466557299 +509753176570993,510393291709325 +508488661273440,509753176570993 +508322451869681,508488661273440 +507495917720818,508322451869681 +505832008521290,505975961783864 +505104443555011,505832008521290 +504458187396917,505104443555011 +503086524084926,504065580293871 +494784913066011,501597240077010 +483089733794802,491369062279098 +478021175479600,479930736974886 +474167461200457,478021175479598 +465490672375121,468431725509912 +458101242080111,459735586680247 +453367562612484,458101242080110 +445556790387619,450155783409432 +433402122350230,441711170197227 +426667061525753,431247335780190 +413736826181594,418488861381975 +403530779750380,409635941696016 +393603100982192,400007830526490 +390684582452296,391449542469449 +388889831860114,389361546156805 +388423796585171,388889831860114 +387342957634064,388005954603298 +385841628276504,387099868619227 +385225479724784,385723673485706 +384062303492569,384681216322539 +382831797388115,383309124794918 +382648957283633,382831797388115 +372200810499461,381433729807607 +364072252149354,370061666826845 +355549183562656,360109327235715 +344567544822203,349413296813607 +333644584620374,340399393006824 +326326266144577,330576407995732 +324591982604436,326326266144576 +316826876448244,321016747706186 +314135853034125,316826876448242 +302312839903088,308713144529633 +292189146068267,300967324704618 +282687875186246,290573385810295 +280560941578746,280797153772328 +280125341259925,280339825942875 +279382596997366,279864345611848 +278367096052324,278903864066962 +277035356038212,277546604653688 +276009863280048,276574216048609 +275896623740337,276009863280048 +275065584385558,275896623740337 +273854340853697,274280134169752 +271719450527280,272525238562354 +262500226361368,270297731427346 +251845737048447,260313551080106 +245990755269494,248893742631986 +242116221432604,245990755269493 +235069912732131,237384252443119 +222640894917879,230010012108940 +213450291588393,219119971121226 +194954655268286,199771011784310 +186228254165679,189071596736306 +171283517818167,180498038018267 +165784313527696,168271206713773 +161619191259504,165784313527694 +151767406860552,159742962812852 +144130629282646,150247654743912 +130978379637895,140394048108528 +121775884964558,128618774276447 +112391203212522,116378059614045 +105164107703885,108624239067649 +93620688615543,99279207187856 +84944235636755,86138442862850 +73539175943927,77764765758310 +63828445382687,66319099818520 +55910578479451,59894189259887 +52984642854639,55910578479449 +43160916427170,45877724695637 +32539515377401,39552166142220 +28856162040146,29629432995323 +27981167005022,28856162040146 +27210038719234,27981167005022 +26498060657296,26711566065301 +25714421842394,26498060657296 +23538316615171,24221552311396 +22290456485286,22692729552299 +21783298208719,22073106064922 +20990176320358,21783298208719 +4534370286402,8681339919277 +2429421839569,4534370286401 \ No newline at end of file