From cf756f04825a7f6f0b60acb7253d7fb499474d08 Mon Sep 17 00:00:00 2001 From: TobenderZephyr Date: Sun, 21 Dec 2025 11:31:26 +0100 Subject: [PATCH] (update) day 5 part 1+2 --- 2025/05/example | 11 + 2025/05/input | 1188 +++++++++++++++++++++++++++++++++++++++++++++++ 2025/05/main.py | 62 +++ 3 files changed, 1261 insertions(+) create mode 100644 2025/05/example create mode 100644 2025/05/input create mode 100644 2025/05/main.py diff --git a/2025/05/example b/2025/05/example new file mode 100644 index 0000000..ca4fb6b --- /dev/null +++ b/2025/05/example @@ -0,0 +1,11 @@ +3-5 +10-14 +16-20 +12-18 + +1 +5 +8 +11 +17 +32 \ No newline at end of file diff --git a/2025/05/input b/2025/05/input new file mode 100644 index 0000000..0d88e02 --- /dev/null +++ b/2025/05/input @@ -0,0 +1,1188 @@ +336566098811319-337408802399429 +474487701923786-477321984437101 +249959673124024-250732034749615 +485427730042231-491324341674635 +215508793567017-216741641602480 +208521390563908-208521390563908 +65963085377460-68562867264572 +403203599110022-407379888162766 +407379888162768-410316986824905 +557257867290148-562274260919735 +535016673969078-539340010469370 +340325900844888-340897997538917 +267533243616466-267533243616466 +354558318115321-358152381942091 +4752343629988-6240365726959 +364945616957925-371004683769245 +184940436448192-184940436448192 +246125950983468-246389816279678 +27254073368602-27863819835707 +224387820342058-230371132621458 +340192926856970-340325900844888 +22745559540630-23582521260712 +146257973155900-149106704589549 +133426317041501-133426317041501 +457434951078358-458061572288871 +456738993958004-457237068938802 +203196395280918-208521390563907 +22745559540630-23214157710365 +21738253426130-22429995031564 +164152387656407-167704337374200 +121546599592513-129862100665806 +196996506046938-198462676430951 +242697102308023-242848386712690 +440387581916694-440387581916694 +44328029879701-48123041770234 +10824367215596-14301852706079 +248991830724759-249671908190923 +247517902751889-247757181643795 +354558318115320-354558318115320 +7187921078202-8535517946988 +324992984558146-327325824727808 +430259278073620-430259278073620 +334436916398543-335172863592753 +75123016642378-79680692210816 +244991861174243-245138829662816 +493527145986804-501579729600175 +164152387656407-167704337374200 +24263982887930-24730366619284 +453157480491617-453687082501022 +327562342284094-329732726596459 +329476449398526-331458014690461 +466340815053322-471815065184282 +28809894350230-29304507131507 +263627281467737-267533243616466 +523764387915260-528745064118358 +453075476637192-453157480491617 +472959134292726-475398042150388 +332864889412399-333406396627542 +423047035138711-430259278073619 +326128564133715-328765570790027 +274441318741349-274441318741349 +458991222931019-459339447370032 +506436163444054-508694499717838 +193550945809428-195372486929517 +476119605849666-478633102761190 +151192496061656-156915268255395 +332864889412399-333127543427601 +42344652917767-44328029879699 +241683498665252-241827411277043 +443781930697663-443781930697663 +29304507131507-29534615002882 +28809894350230-29304507131507 +496555879264230-497927894940614 +156915268255397-158042605202224 +374667004122140-380747645639964 +312639462899835-318676175799901 +250519494417301-251021195550869 +274441318741350-278455061523695 +247517902751889-248255248970966 +302243631309925-310380171638436 +283128359794483-290169400007104 +232391725301276-238713510398280 +247517902751889-247959634385528 +332113337516743-332864889412399 +2499527836808-4293037988065 +14301852706080-18176512869247 +21014357245246-21738253426130 +133426317041501-139764524734549 +28319450338985-28987690230652 +557257867290147-557257867290147 +337931200505107-338475906200901 +343485227120057-351026704707496 +392720969540406-398150352950082 +433402266950738-440387581916694 +83827625028534-86570614737725 +363006070170847-368749825565366 +23031058260379-23582521260712 +318676175799902-318676175799902 +244991861174243-245734854092672 +458061572288871-458836399260436 +195799144388388-197580040466197 +488479801530342-491324341674635 +34397813664404-34397813664404 +517242404413661-522375391736113 +292523902046334-299981619411875 +143708019265221-146257973155899 +455981197702225-456481281085662 +3748334813066-5420992268713 +20436370193828-20691993847924 +243310423787558-243651445496298 +112250917862250-116296825072047 +52998694266417-58893501672397 +245899464235291-246125950983468 +384738421053458-387876908075215 +175475627620851-180142486031845 +192256643802372-194041419331372 +7994126068579-9560062807547 +459560468170564-459990950376756 +232391725301276-236437848054398 +171642957024437-180142486031845 +420668460362907-420668460362907 +460880935210074-461003862917054 +478134483429030-480662210872277 +479748520121479-482096737195811 +343485227120057-346878114107901 +194598062012478-196436448877176 +243310423787558-243651445496298 +82681114767183-89072760947026 +112250917862250-116296825072047 +184940436448192-189902212010148 +335870703252328-336354636317165 +283128359794483-283128359794483 +249959673124024-250732034749615 +336566098811319-337408802399429 +5721609282332-7620695456668 +295036168095479-296839352278880 +337931200505107-338595239953940 +199063739170072-200939977745849 +455104473155394-455606892130714 +337548608057813-338243640257328 +22429995031564-22745559540630 +463970787392803-466340815053320 +20193919567674-21014357245246 +398150352950083-399419751402066 +248398856491167-249090951162375 +61032320290364-68562867264572 +506436163444054-508694499717838 +24440869465563-24946077819020 +323575150117156-325360124292859 +1276540942943-3152355546365 +197835106344014-199772959835389 +527179852838824-530683739440807 +322258474897056-324330135941727 +25274755547260-25793124052420 +461501482647802-461731829021950 +34397813664405-35889724998976 +121546599592513-126927355366855 +255015395258899-259622120267858 +544988139928091-551929359499591 +514488918319381-517242404413660 +544988139928091-549115904544222 +374667004122140-380747645639964 +27254073368602-27863819835707 +71812554505230-75935165444731 +241384227973286-241827411277043 +58893501672397-58893501672397 +24009226723279-24263982887930 +223082273803282-226615007087321 +318321327621-2000604286918 +443781930697663-450867195965087 +104747179050467-109097267131461 +212713992782222-219650448157128 +340897997538917-341084959437207 +336089814246543-336354636317165 +413838136628098-420668460362907 +28987690230652-29534615002882 +94143750134639-98586182238539 +305612028203739-310380171638436 +460629822509596-461336936899782 +452752960613735-453157480491617 +29304507131507-29828083138406 +249475039981803-249959673124024 +458589493376332-459339447370032 +191195578167684-192849580354992 +335870703252328-336566098811319 +337408802399429-338243640257328 +98586182238540-98586182238540 + +230402443778202 +21580645493481 +368757958942253 +370883264225250 +184472463065710 +412312621329505 +530413138925573 +335247909147000 +55134538781151 +499487718245898 +262642348681868 +292963800734937 +321157736220084 +57567139922162 +355813209010472 +103413848483305 +501004126771822 +497275254033709 +544194406272457 +147304910612444 +89587293166533 +45830253018578 +425833047869107 +349082691399279 +135076932568614 +504828760688619 +556166073861630 +16275361877650 +57799543968531 +265619952974037 +472247231424284 +487113933667134 +148379069778905 +218868093792299 +298325716274079 +477432442490769 +517777857934606 +404377441536610 +185004001218813 +364816892250910 +499726209717247 +99924226889424 +312489340802680 +69950827138691 +223292759748813 +489850532667409 +21441036224881 +121150872642053 +393652147025660 +50149781578858 +85853125395480 +223299055069470 +212740892445702 +347658465107987 +36045276789211 +554739727114466 +336566640505381 +22555794771619 +540838561654517 +200085843147659 +151674978263730 +164258925019613 +300440361571412 +208078138112158 +128884428947923 +470931632160454 +438124329548756 +418367551406192 +156612978346964 +552612096892799 +11239458547600 +259364591751831 +307296621590643 +28846181659073 +90680652124024 +155198372728986 +198671322395657 +252481266746992 +307224881413677 +38354186077160 +241660245475668 +493906101042752 +496610615198621 +209221144801944 +438329521366641 +255647089175125 +139213412501125 +317555450282432 +150239394298365 +13029952363185 +371047637439505 +343610800719894 +208750170010034 +186284427899578 +277973985533168 +544813254701274 +349643473053111 +126431959452796 +453310179586640 +492789556379307 +65969787202901 +495112112988452 +347317983143318 +219724582765395 +330189701000276 +470191968849858 +316458482538045 +149839326972206 +467845091835192 +369142182843350 +347816241039095 +335932000050931 +241113558240 +280557803801766 +448060525089632 +191712116398120 +188485513255754 +374991218416757 +289052872118353 +2306784222200 +100662624629176 +455665062279267 +497286226379886 +463773407251124 +131099861097862 +252155974260677 +453238722554096 +233251205428337 +469162124455970 +456462960594100 +48321891192373 +344281415599415 +496096798767520 +137046084308173 +74754511373722 +321431164113777 +125342552440353 +482344933194139 +427271415357368 +561776787962586 +258739473029209 +369744224444774 +98459255263254 +459350206853795 +298656658194406 +343670943493788 +77995237680729 +253450105434384 +94148769551136 +541660344215952 +393574356457105 +466654121559060 +205180351436181 +54660640537790 +401199441605129 +455431160472240 +419133722624130 +290898072601796 +123348532764173 +155513082280091 +228362402011104 +71396520599690 +298686765252181 +74147449761678 +228342450958767 +59559283143501 +112661841035968 +225445356448947 +251334434250432 +305004298345956 +79531382592144 +101959772251508 +191663643878412 +247926893294287 +66626889913954 +322221567240115 +365248984865546 +287866446610032 +24287206093639 +217496979342471 +291504768707793 +199094835718848 +220472638902518 +345516388160290 +529448713205725 +310494066831918 +369453730314025 +211451760900009 +372501836272485 +115251974020000 +2013977211203 +34261455994547 +422600963644246 +16309050916318 +467943090967738 +279180877899064 +495300674449172 +543789094495435 +476060862436585 +29587456256749 +35222156684482 +509280856650344 +184593619526248 +397213209634610 +228761518946412 +127085110972149 +336348863966083 +189879742500077 +172305031614108 +122922129186703 +30550941372875 +407622755363512 +486656235398088 +458829678489172 +109813208862097 +545454295852322 +338901024735657 +419350285318154 +245871541422415 +2112866624810 +169821634461391 +559174416562682 +347817541664760 +44825467553819 +56983903212597 +128444057964595 +398534931101394 +480577376864557 +327300323360649 +310487542563466 +146775949813270 +196680441779604 +486709766226695 +475319998187133 +339203438758004 +295686759051632 +229595398355618 +446708646470841 +547588157686640 +12634100459422 +4358855350014 +528116744262153 +250569798186626 +242750841234621 +300478865372902 +372674860240270 +52320251185107 +281206375980459 +57789294511253 +380397888655374 +367668489173474 +93796427068213 +253042098887852 +489913971443740 +435132490489348 +527491903391463 +123451067769524 +401703122867678 +361897725987194 +51002871937350 +95686213266149 +439419226124907 +487532658089733 +235417877664431 +453898457877700 +8934312777419 +195065042425401 +272783884591041 +136416757907486 +180138105266998 +144965804437645 +233816713622857 +321217867169704 +123799643694317 +199307754844440 +449746069796375 +193575630897739 +451841471283863 +306554009897607 +444266652444778 +168437000333754 +402636901961372 +32932325075570 +200384070799294 +285858469272454 +150386815158328 +515700917809345 +284414509347319 +413752096596131 +157416171109429 +483440315089898 +551181111246817 +554219404361279 +399664072667901 +410097887807067 +187897730193061 +273532208144287 +76502234469366 +63547821695141 +122475614537274 +332358054168500 +432467179932010 +196320867092352 +14139250886562 +52599922701290 +3397068367885 +525004363391225 +255131274818586 +2645075133223 +32991934261060 +20825968070914 +442300044938928 +391466450270241 +460603984276402 +58469128527534 +41743173992863 +409967620043549 +160673647697810 +386708601845506 +52842107743499 +10536030243500 +102209345590986 +20651391794467 +73975040043854 +382427000506506 +538297660298608 +37268073149109 +349105187582329 +227021059376507 +529731346795316 +97660817491367 +470956126957644 +355762037001681 +237063033582405 +349646079098539 +433641025824121 +531404957495407 +201905316100923 +33943460254760 +310817762661355 +385530238244838 +347946496384509 +268302310949840 +197584148716522 +183182279544041 +492600210456748 +172238481770753 +416891501735909 +416371063767876 +198624914299076 +446023916271714 +363095740685498 +265753151105293 +515373572208853 +488183843980988 +5973918574475 +242125745267543 +455348071386762 +276492987759787 +59717070107715 +77875815147840 +74637188508361 +189688247261554 +139084598396378 +183260780896433 +11884447211348 +416613353002453 +471473585588903 +257803739081786 +165859656416035 +374990060247032 +122279991074502 +281740405810142 +287197891476118 +247723232278755 +43977752706075 +17524649262173 +518883005832440 +28759273628975 +39014467487014 +139212927927046 +244125475083086 +507719904639228 +231763825752144 +553970662611004 +288106534599508 +161416439968411 +22632669560416 +119015826240610 +345866153264090 +259494504876409 +8944415439810 +191719010247282 +367103101009867 +247597253499793 +62714701287414 +273634672454120 +44629850720835 +138632937327887 +190492147658650 +122589076852537 +246197267575 +163114989228251 +478520872145977 +459054751546379 +44313621669723 +261469090796010 +24587750328932 +184409644906436 +184467785985026 +360528326260853 +185839203688672 +530462192125321 +190980438765614 +424384318742048 +288657725015174 +146439475584870 +96762049761974 +500482307393843 +506693891489728 +427269664683108 +91437252778426 +135735981648751 +164717249584010 +182023972795405 +161211698952235 +180713183497396 +428440410651175 +433660055189676 +194056687094642 +368518240274507 +460666638953461 +360327862937117 +107814606753228 +296247461090738 +98587363173700 +285693585570890 +473856240037036 +12911935915252 +561380608177103 +262736116332916 +490178129339976 +97828972875280 +229578781852417 +402861365087636 +27894916638083 +381904464926422 +409859746428906 +12475152574001 +186674133275443 +273651832460926 +170801014561379 +445659141061577 +466257942230195 +510859186922244 +121239459816265 +525489973619921 +518622000986102 +463123730813872 +293436776061777 +328834489019183 +355888827792889 +97491411200786 +463809045104770 +250784780138839 +429388726910027 +536778043258618 +289003156992813 +222677620225720 +315115489089803 +163705277432455 +50081191650914 +19576244935396 +227744992979837 +23759534430085 +397919894952807 +459006078451727 +251374452260912 +432514013838116 +99426387669971 +187320078540743 +27212296788944 +188194893182683 +187123675822374 +94839986875008 +155543435385413 +239310140642124 +153464565468238 +185600508512858 +462808198445709 +475323454421352 +127822600058132 +9535928557649 +360263835207363 +231243733923814 +164925428846233 +399252158389871 +18434102100933 +8073072082148 +13190350236809 +13183845826945 +303776728368452 +133584196332661 +89370599692319 +192882935480289 +89590609025288 +285894582520012 +300559249366165 +106804317313287 +516742433734140 +289244953377421 +263234845871463 +2814098202675 +28599984524124 +329668228282218 +300445628843655 +218584227115875 +400312083023927 +103211690027338 +508085603956920 +413992074559577 +62719111117245 +256217467940483 +461097706236108 +157190255405845 +344609979699829 +56039689006985 +329554052127348 +394503221038968 +426469810826380 +489277067240692 +282111028959176 +526015008237844 +442378776262118 +313158927674167 +117455518420727 +446809303841058 +369691772708421 +555093583585709 +193827616258337 +341829004044908 +497756620789221 +19640894916900 +47584460700741 +526266218908217 +145500523121915 +528871857108321 +218865223393772 +391298493587549 +348371694566443 +514554982764815 +27072700176463 +217152487749634 +15410535661868 +329303252430195 +403230987474697 +248471587037712 +124859484063172 +177163811657111 +112871451450301 +103976067471848 +134326868552989 +255539972987936 +140736782646537 +429142441720389 +91235141517787 +463766198313877 +505223937869266 +187184091249436 +251024081211052 +4881619727470 +350419521794463 +94319378629766 +547560350249786 +126091705979966 +430359320995731 +321157466507446 +500686363502128 +514679403233387 +514564085270602 +347852393256685 +494451179742709 +246975350014171 +271955327463472 +493257351772748 +416865760896715 +225023423947464 +42618539649857 +36127873649849 +210558090814072 +440019896206242 +138877550487943 +479932054043511 +142354601063062 +256335704868329 +205473989444076 +38546695570763 +195203305994580 +391373904529265 +244714688679026 +374649020892395 +207812153122069 +342978544825137 +127817724240863 +471339540980835 +375176174800253 +1911039980737 +21188294393256 +112645256904746 +71326968589045 +369599060867820 +174495294427247 +381346211654740 +77303877937353 +60283264841191 +229508419032776 +337033683486376 +131730701326323 +73245437625134 +240101159366468 +255914432118750 +124625627493517 +309207606212780 +142516299178815 +69017934315229 +546223250585261 +353725999555456 +264004934652312 +195494031770746 +296373174640925 +467196771183168 +171582420438216 +146715563427286 +550430177716505 +551063872627951 +486638468704460 +497585861622888 +369795330920297 +533062936130959 +54592709904987 +80270111615510 +530779448500844 +330742117541709 +240020077189393 +198403124787040 +360327075099785 +314675793508811 +70791814495976 +328007744245980 +265867743275776 +511600981300861 +65977705115675 +543276217032410 +71373745388607 +436628280343178 +456195602851114 +165143929445462 +375404756585241 +502720765790158 +395279202048538 +367945148961614 +379504589644410 +95140093745420 +29783970203845 +198078752211749 +203863098189876 +428098597311680 +52643035089417 +17611708702040 +214724530700125 +304607383887035 +20912630429851 +172038347772594 +371261538068108 +11512336502102 +398105439635300 +398236803528907 +63941849842488 +110828704910881 +31125718744105 +126312554348727 +67402362371735 +459263149023632 +446557688486930 +86735273690821 +536877301918220 +362320201643809 +54133955603322 +171112962716440 +77397221254561 +233671427691159 +507939749545842 +216851871513855 +517035544828212 +381328135403430 +274245198023098 +451857521029903 +261628704901883 +488809928898937 +547813713727100 +53163028444092 +9758520749245 +142215213571498 +444611453825789 +103806223369386 +24797563950851 +344818763301330 +191555854129143 +8652811289548 +251852025935133 +552391776771997 +368914215466620 +395282052553647 +51725433304946 +21236615043894 +446324412616992 +235948364250447 +246295092697066 +52726717296549 +189551400947756 +206390860205895 +283440931999044 +340570954587531 +112351220881469 +464671816286459 +164895070603862 +356482417406046 +177422369849926 +347750087827282 +489120480148796 +152319326953586 +57283793618390 +165420751024002 +120696879603439 +135092094423448 +463422246600159 +387752530631666 +527576269850604 +448490633965690 +406893211603012 +430436226992095 +553299204761125 +202285127710656 +368985933275699 +560285567969477 +424719713596973 +120057094080254 +437473155960240 +46353462145005 +250313301518199 +146217750335832 +96393597138171 +465771587553077 +166159052602385 +67699362269336 +153052073379197 +460248009070235 +490147369025505 +419395430233601 +240985575049374 +354876602723793 +529689975088097 +522644108692440 +154036297230753 +98712670324939 +323639323672963 +305249928176352 +149915951451615 +151217581901803 +231967142943437 +380223037017905 +33614808689675 +262932189731410 +410906932646260 +85581936980564 +218749311212897 +5242722744953 +256319444120172 +508520791125658 +331016888505046 +287612536546103 +38041543812192 +476714576240337 +482977169130597 +97590603822345 +194486000439354 +70833316422555 +149825219543421 +7700447841505 +50029530500160 +67822458550463 +16285186971306 +558740114636340 +147869685849286 +378213829911528 +23004535068167 +537843923657195 +301509738445770 +430152870481540 +57084898399526 +399265421832650 +109420781665161 +218922865569668 +106996778377224 +368531185616877 +98941308226985 +55174729832473 +488398941488360 +16024849052814 +402728100434094 +366179161748967 +359877690811551 +391589277482346 +284180573646125 +23346570048946 +340792892661989 +225520780975089 +395732707504553 +518826648959635 +6077777381584 +395966596788666 +306976630290672 +491138109451230 +250053558564939 +151890889645427 +332410246696735 +2794754980826 +141599512955508 +378649583042233 +526302975961862 +366946643332464 +381696781307568 +398354853446135 +226263040918810 +254078149486811 +216183780061261 +56671880079504 +539761416723669 +354777056033344 +135307722379278 +164239316019961 +529788536882824 +506824801046290 +339097167802647 +523392799462040 +209247550917551 +141188850046881 +301467376377236 +76325425012043 +517124884240302 +389096579752571 +263309764213116 +371324120363377 +341262842149581 +151492250730167 +297970825402472 +337176546945574 +443137640690476 +561330441771524 +386566314328402 +446177713703448 +93049014913195 +457735298425240 +9080642071492 +527084972884738 +396894173612416 +200658796985834 +250768644613262 +112038606679635 +536738663078602 +14241175289798 +156289252930647 +111757136401744 +486450700358000 +448754849203746 +558784389487076 +494703855782437 +536678575641819 +129957366154629 +85261936240162 +506698882018013 +168620935547541 +363166546200888 +450635214889038 +338089451409712 +287140879127203 +263869676126335 +378287567385520 +308462993311963 +388078485297670 +215948678436636 +364799253076063 +526136930059472 +289693676999144 +206914926483343 +494644872397993 +323037681844235 +406772770061977 +154962669938783 +199698354011633 +422572247245478 +306523633175032 +561941619685111 +481070133330959 +411281146185133 +134369491135185 +130259513193726 +448605635925021 +1566851243388 +147693830836593 +2052766719211 +96562807467770 +84346636472718 +390901865271203 +32796984910986 +305253639076757 +466339896719875 +274761877250846 +393953139525560 +171250074485920 +81020023502609 +284545128658237 +455875235401068 +113695294210238 +424073789439451 +303424722924299 +378093858845065 +46958603946381 +551304575184556 +412758340613647 +29275871345007 +425557906223410 +41508138724647 +378377505266720 +117265135603961 +439960991593655 +516385436112285 +202992230712286 +459426521308819 +17613133937522 +482772177774692 +479351331001638 +246484141163000 +375036871543375 +121575305005034 +454029288475529 +404425532551832 +84047960052342 +264496746740339 +82633909019178 +224526195282490 +1493015994687 +188104868723244 +37840586734277 +537260768737808 +128448588633528 +560226810721597 +122592550140269 +313258386713801 +506863036327037 +353788824892658 +516798424809757 +179023833822486 +62462768008249 +68158556257287 +427675920328719 +467967175115234 +536464086205407 +313339614844184 +51175102722951 +180849524571774 +170879958626821 +258833330014444 +349523588980936 +192552500880096 +35559720092638 +386338639982166 +123641889583095 +71389479687388 +256000079500151 +178087078139164 +522449622878822 +474662667882603 +155224351269072 +379157085146633 +160047574802485 +241060016267618 +11729737474293 +356766905074442 +551908713415687 +532909300225706 +488817912669887 +270881255598612 +369601382340597 +490651661320271 +47842865041116 +76649545195134 +145551594565099 +218452543267791 +370368993695782 \ No newline at end of file diff --git a/2025/05/main.py b/2025/05/main.py new file mode 100644 index 0000000..dcc88fb --- /dev/null +++ b/2025/05/main.py @@ -0,0 +1,62 @@ +#!/bin/env python + +FRESH_LIST: list = [] + + +def findInList(l: tuple, ingredient: str) -> int: + fresh = 0 + + low = l[0] if l[0] < l[1] else l[1] + high = l[0] if l[0] > l[1] else l[1] + + if ( + int(ingredient) >= low + and int(ingredient) <= high + and not ingredient in FRESH_LIST + ): + FRESH_LIST.append(ingredient) + fresh = 1 + + return fresh + + +def countFreshIds(ingredient_range: tuple) -> None: + print("duh!") + + +def check_if_fresh(line: str) -> int: + return 0 if int(line.strip()) in FRESH_LIST else 1 + + +with open("input", "+r") as file: + fresh_ingredients = 0 + f = file.readlines() + lists = [ + ( + int(x.strip().split("-")[0]), + int(x.strip().split("-")[1]), + ) + for x in f + if x.find("-") > 0 + ] + ingredients = [x.strip() for x in f if x.strip().isdigit()] + lists.sort() # .split("\n")[0] + + # 01 + for i, ingredient in enumerate(ingredients): + for l in lists: + fresh_ingredients += findInList(l, ingredient) + print(f"# fresh ingredients: {fresh_ingredients}") + + # 02 + FRESH_RANGES: list = [] + total = 0 + for start, end in lists: + if not FRESH_RANGES or start > FRESH_RANGES[-1][1] + 1: + FRESH_RANGES.append([start, end]) + else: + FRESH_RANGES[-1][1] = max(FRESH_RANGES[-1][1], end) + for start, end in FRESH_RANGES: + total += end - start + 1 # range(start, end).__len__() + + print(f"# range: {total}")