Compare commits

..

10 Commits

Author SHA1 Message Date
8b702185fc Prefer native types to classes 2025-12-15 11:00:04 -08:00
5a70dd3810 Solve day8 2025-12-15 00:30:08 -08:00
041d9e3bec Use python's cache decorator 2025-12-12 21:25:07 -08:00
6c76a4a921 Solve day7 2025-12-12 21:10:13 -08:00
3aa15fdbba Llm's idiomatic impl with groupby 2025-12-08 10:51:02 -08:00
ae88822038 Solve day6 2025-12-08 10:41:08 -08:00
6aca754e5f Solve day5 2025-12-07 21:22:16 -08:00
802506d860 Solve day4 2025-12-07 12:20:13 -08:00
953d4e4df8 Solve day3 2025-12-05 14:34:16 -08:00
1a7840ab37 Solve day2 2025-12-05 13:58:49 -08:00
29 changed files with 3128 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
__pycache__

1
day2/input.txt Normal file
View File

@@ -0,0 +1 @@
5529687-5587329,50-82,374-560,83-113,226375-287485,293169-368713,2034-2634,9945560-9993116,4872472-4904227,3218-5121,1074-1357,15451-26093,483468003-483498602,51513-85385,1466-1992,7600-13034,710570-789399,407363-480868,3996614725-3996662113,3-17,5414907798-5414992881,86274-120443,828669-909588,607353-700604,4242340614-4242556443,28750-44009,935177-1004747,20-41,74678832-74818251,8484825082-8484860878,2784096938-2784156610,5477-7589,621-952,2424167145-2424278200,147085-217900,93043740-93241586

26
day2/part1.py Normal file
View File

@@ -0,0 +1,26 @@
FILE = "input.txt"
def main():
line = open(FILE).readlines()[0].strip()
ranges = [
[int(n) for n in l.split("-")]
for l in line.split(",")
]
invalid_ids = [
id
for (start, end) in ranges
for id in range(start, end + 1)
if invalid(str(id))
]
return sum(invalid_ids)
def invalid(id):
if len(id) % 2 == 1: return False
a, b = id[:(len(id)//2)], id[(len(id)//2):]
return a == b
if __name__ == "__main__":
print(main())

27
day2/part2.py Normal file
View File

@@ -0,0 +1,27 @@
FILE = "input.txt"
def main():
line = open(FILE).readlines()[0].strip()
ranges = [
[int(n) for n in l.split("-")]
for l in line.split(",")
]
invalid_ids = [
id
for (start, end) in ranges
for id in range(start, end + 1)
if invalid(str(id))
]
return sum(invalid_ids)
def invalid(id: str) -> bool:
for n in range(1, len(id)//2 + 1):
sub = { id[i:i+n] for i in range(0, len(id), n) }
if len(sub) == 1: return True
return False
if __name__ == "__main__":
print(main())

1
day2/test.txt Normal file
View File

@@ -0,0 +1 @@
11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124

200
day3/input.txt Normal file
View File

@@ -0,0 +1,200 @@
2343453422641331233623444434443422422234243434644344344333436434324443344243444547343426444313413747
2855855566364334765666447534635566585837457546445758633538786145597524554776646675584566565455656556
5455463424234236523423334345455444634544436464346444233423443324545464444642452442343353644334535444
2124233254222341223234331212414222235244222662443314232452232262232235554242154423622425435654322324
2332248233225212525222222222422224122233225221134111212423421231224222932121353232232432223211532422
4522542214443113224544155153312551232133415534125211224524241324115411325151311354453135113331246789
2241242252322221242223222222132212223241123122222222332211424232112242322221222221222222213322231242
7558353283677636733775864478467854665632468768617383354484675381162763838872387571737687774846684654
3344484433233643346335641434344332343384262314353743523322353211665123643238344431443575325633536323
3147453132344582341523322733213313453222322212633252634358623552534426832257242225622235213224635634
3237235525534242412132322246222232812264423245522122342232122211131513224222325212729244233245131124
4333336434124353433333343333323366534353664383233333523826239336333433413543623643323534478813453535
2766235215236263132162732763741151462251562371176157453722631453144613175242354351673253677254421489
3413253442324513647314443433354345443432553234452534443623342426643234434349356333244333349324812364
2212222243123221262342242212233143231222222222522123133114132321231222333222633122322222232224232231
3232415412132232421512323622232425324222473321336122143421623323221422137322245226231332232225214234
2253424182211233232241541273352121734324726255222514222332219441571224324264222212211912495321532427
7232352323134372249422321225261243243223255231333422225362662321263682332643365223623342135225622435
1555255555344553546445826521266331452544523334523353344154474464345334457434535357553444345423654434
5537524812673574646632245334349593676339361575654433333226337553652447744445329678745522254574556752
4332543748231224333359532233342222323534352641222342434352435333423613344635343432244225557245144152
3212113222216224552454254125123222222524224422325122265262426226232131555132344362165455234225255412
5545773276222653395365823596435838555937337443533621555822767282435283214925323134882243331558775558
7434233344426443414745383444445281433534444224544434364456254234444445433344432134644423344127663443
2613243233332242164312332361332423222362342323232133225322333335263323325222262313122632352223325222
2223432333362215331532333343332235334622312321353413642632322322623225323234634213363333433332222335
4312424322755333343543452253542541226232431525646422322234362124332552251325655213421522442744522423
5897273566379433451223339476376542424217232367225273573257987533594789893665739731781863424833771362
3423262121432212263544264655433244243336453472674232265234546422135445472235524541124313441123232533
2636534453363663634445344564326643344253235574433453654634435923445495656654542795539532232555465393
2254271735834672683332374644393773648253547338465332353324736226624562577324349348432363445445334546
3377446237663363646946545735433942818724376343147741848477529447745384834548384753336567634223764767
3444544614365554343354444424354134434443349443244464434454454455553444654424434433444444372465344744
2233473362334422333733133234243234363636333333333133333342232352343343433433323323233733313333334343
2525427674556342375442823591327563445225172346422543523315235543332133322417435412434362435332333425
3252345314463233542663242265722441426263624263632333362633136367342256322566452446143323344422322425
6345563336362334322534451552334419323323363272333286925462735424664334238734112363522323583534433223
2221222431555226214114227622733212222312224771622623222361223319224322322222262212222124221232312223
5444453434133323373146342345553434532363433344534625533355754433425332523353344435753333444423335448
4562894651264437434643452646227346638154452413661221564553643451164534272373247443573466674224631434
1222712242222222223225222222222232232222222223244911231122223212313212224213312212212222132229223222
2432334332464444733314224232342343333444443432441233244444332433444324334532223333634333323362342231
1331211442311324142232241343324444432441211444431442312321314421121233432441133243222331142221256789
3423143422334244551465344432414221122252212553444321228442344243325244244445424442733334542343412133
4233344264833422423454123186424323623245326143335343271212423431733444333174223133434422432232233336
3748457795547753473644647796774756667765796447574677646786677547497787486775694849859649466477895776
2123332234222133312222328231363332221332221224322211213232232233222332611131226332223222342133325243
2222252244452256123223322251221692332222243924546241253822655228225153864212723223255322424123852425
8422112277227422222265263925523626414155352122811747711329144776232625171534225682395244535322642881
6368656453953669934545339796965735949381454645537897765556377129998839756579714745557429955558748565
3322224425221252131222221224332222247225892222222222532522122222122321377222112224126323822221732222
3335645455344232223343127345643233233273322221452312354493333412332323222264533323343322393224222345
4241413543324233313223234429483222322147227232633444421224442423343254326243221244332315243322324322
5574237447375775621363828563471836176181324458837744833462486566764446487554615821131367112148212469
6534573266233533276565211675443236734572626837145323442495971334372252936422625743235636534751325323
1233424432322212334422342449212243232461232226444233132334532323243426233524514231214432343114312223
4354555443232413265445532666543337533264345374733576543456247234443324526132445323433333646364544562
2534234436317222732222822131932225512215232232236662322343522723232222533334222224222732332722352312
3452343435344422434335333335344344344433253434333463444363334433344432334441423253353333455444245442
3737633682743282872722232722522232221432222723522124252224112242882222228247723172271122552349583212
2771223222232332222322322422262333214313133223143122332222332323121222222422233422331222221442322242
2422211225231221242242132122314222822222222222212272216252421422222122122622293121251331282134322246
2222222221223242212223212122222222222122322221222122222222222122222222222222222123222222223212232121
2222322125225232242242222221422222224123332422212232233122224232122214211232322212232121124422241122
3122223324324232333313332112321332333333132433333233333432323323323422222242222324332332244322223322
1754365457465529653213846457756246255489665345623644352243546864661855453846968245755486351156346559
3335332413222222242324343443422322334332371423443333324313222143334332343333344412311431343333233326
1534433243425444743484333435384414344234734244342333332324445945238334451222354423243241432544524543
2322233223335221423252223322232232353422133133132332334612522352824233231142234423222132433322225323
2233344362433332443264533233433842272631223433423951223432123233433843323334345235337346261238375837
3244222242252342262264232242312122324327242244442132344223423323142228334223114322132232333123222323
4222412222222222222122512621222122122328226222221422222223222262222225322421224122234222211112222244
2132231232112432463312333333133151254422212252422223223323232232342239627232322272373122333333323422
6796447426869544576625778745446655742364774763674665744845574467153343745635846624563663617776626546
1332377852358533652353422333645933534424834853376443445469325234453734733853375454343333763532563453
1522257412442212575237222125272242222231213423426493623212532322195136226714452241451231412225357233
4222533312252211232332331244233223333334513321232432222433322322624122431122722415223332333415322242
2524352221221334242342241433722251221124453721222332242235322453345324224414545241437355521429243433
3242232223622123224335232132123223336122324213322422223222322231222222135222312122133222323222223251
5832462422453335543333333435353352438537434353533374333323352323363833233542533574344446413446431553
6588484555555555513599692555778385555553755555453566564555844645849855544655955543254555566515856557
2241322452438433332252242363252331223225422122265322123314324212222632323223225565123445211233342222
3655447233543637292965466985423322455935425425252554339536672539522467682855634377344536545594534564
2411514322424227212232125545544212332122232221125522514222254292126122452121242412221742212565521122
2363763424225125326235566565624632625365226263334674144662662542624357344246956727554231435225222436
2552442235423354432343243531744444455242535254646232341244443332242431665344432346343642363343245444
3224224338462322441443334422214322132212333344226451232324224222347132423238324324327227132232422552
3333433233333233323433423323333223334333343334422333122333333423333333235233333333333323133232333334
6566273357637664663763666346678374675694635874799635474568677565737877579559546323663653457432875584
5534231432364243372346335363226542237153375222325324371374721243244336624634232777532553448656644323
6343338344333143455372344135233232233336276133335323363237334323863233833543522734323353335362733323
7744556355597685874673673764568755758373766334784734845674963473335796648778365637647366473344758434
2213546516252854516422226532192312212342243252555363425234223343354538657245534168555132242366758244
2223251232232168524236431213322222256225544222123516222223252275725362323381926231332542531764322237
2322232332322233323224332221234322332212332232472223231293433323422223233432422331313211232562213313
2224144174433753323212724187982228146442211422922437222483211443934432233834293224222222237151252124
6564453313487332263646733648222445665357223544243434674574435338583255333344574631567736274725571443
5254222222265223526321512223113323522224542244247226222223222228312214322133233545242422231242222212
2222444354363533827352245422523223223232324384223333425342427334512333348233413328456343423323764433
4424644423232313434422335432333533133223324433314422234324432213343242415262244232432341324571423233
6362545755588453455853768234465888547656656556657575355254435655865355656874647355265754654452555764
4424244132142252122313322233215122323122227112232324622422121144212533225332222213422223322323252235
8324424343462334943935427256229244623324232319324554244223433315235422222819214473923321144634224422
2343334463222343543343333233344343235453335333154642553422323334333333336224243544323334433233223334
5622125462312421515665231253315266217262328722234222313232633234123232722222463146621744653356142224
3233533232223423244643332435552543433222347442231335537143243413431333333333235354255433434852255453
1545211254135316354413322122543161335216134366461314551424411115516665161554621135163264243524342789
2112322232122212131211232222112222222311212122222152222112221221222323393331162152222222222221222232
2423322232233133223123233633323243213113151332211223343132233222226271334222623333232323232213375332
8539945379743134534782852443322259494415551439346468277535684323385394596743573467814532643446334469
3217222222222213221313532231524123113223222723332522222115221422222223222122213252112222212322382213
4769797556895859326665476278466859386486766484833559676436383847888376379573795764527895778756555866
2312222222212242221242112221232331222211322242422122214222221412221222122314241223211224212262225222
4393377633346336436336334623463665635543777582453626246133337429335337543541337636746633937915438473
4464472544443433743453334433446635561452377546424463334433334864274441442735536455333532734624257634
2322222531323222323324313322241123235232222321141242132122323322122242112221243232242124233232332342
2223332222245242372225215322232231315136222332132232222224241322323123422232232323332222234344223312
2746333543453325833485455238452332448735157333631582785254652745526425755425425584678834275396252573
4444444435434433335333243431566434444233333234642633434443433432526334132354433324433344233434633433
4655565545553655445656325555555555554645456453444555644545366446554555654555547652566665554357656545
1223234222321331393212332325241221294321222412224322233222423392222324112834124222222312362223442272
3326225243484722436725227463266722172243634373333722723564333133754237523133335357554612221323225312
2222222216325112222412225222322422232124123122272227214242222522225221342122222222223262222212622132
5343335445543544543341323435445235433323314434833454294433343552533354253525643135343364551332814454
4554753424724266354564344736755587267565958786274747366475882726376678677483339735785733572846585434
5145132435463444436463434634445434343644365444355346863479445333876623535333334343746636294634343644
4242333434243464553425434444123444343533344482332346655443434433445422435324564422334541422443444323
4424434344324558542454443344354554425125734545344234322345553454533964552654345443323333443423433323
4346445384342232435436465246434331474344436624614844745443434335444333464443947943344444444844446143
4775467655388846666366656666466346456656385866656648563566555575574655744645434755535457555675766655
3627232324233222344224224222421545432324214432112334434442224234623322222233436141331311346423322242
7735429124135653424268213146643241455965577261243733222724444414362143243535712322332252364572615223
8584326558526657567134262566656416123532665357444326284645152161461465336562563376235222624927725433
5165293733124224422322555234639215522553988527543525454755725242323444954354353242241322195158554372
3392662245353337737322535332334542636584648636365547343373155533263446314676652364266134323234436243
2127522289122222222225222242785242293222241252321327352226228275224282226252682121524547212222492232
4476675867785865646473557576266868886665464746657496582746996445346577144747536544494348346587584476
4342376334563624433458434272133353545474233543342443374576532334224362542433333332762224233333333533
5252252324212232212125352234224722224222324254211222381222122522422222411144321255222422141423212222
1313346552363223221322122211354362212433622422532125326215252523555212323322611216482222234124212212
2212323222122123221234222222322214322442222262211532124223222222332211123212132142243122422422123122
3223518342212862222533322722532222211243652211431814512525222442412411442342132123222224242215222142
2333223213223223261242433331622335233323222221232212321122413233331532224272236212212213222223246332
3222143233135334342432232362341332324243724522532221234424722132241423331234533334323332234443342243
4355343342354334425433324534513533433274344143313344355444544533443343454355432433314643444446444153
3923223252352517354222432112253243322445394345144223443323253273453342462352333233438331331412332235
3233125324616753252422337231933421267233223842322132222211623425223233232373613321563242222632433233
2543224823243445343433422443222424444331242624221222451422423333121628522322722328226122822223441334
2243132222124232222211224322313321243262212323512322122213523121222422322432232222133212161122222224
3429376727259635133541228222462577721462169685519922652473662652725736325445147425245244333423645645
5211535234437522233534433415224552355734323354313214556375315735632331254632712585433337181242383224
2333333333232342444123142434233221224623533253232323833422312333435334333342242234323213333334341323
5743223626322733473433463247236634664357335333436322515263132533722337253343513337242333324332342361
1934446965833831875835524541555358437946537488651524522447255569328347227465455693455469844534265459
2224323152322226322113212322212321234222221222122251222223221731311222222322522221322222222211222222
3324543225244234222333323343524444223341543222242448344224123423456432522322214453432222232263342433
3322333222333343334232331323311232232313323233343231322312432434322323233321332333222132335233231332
2321223362323212325225224222333342133212431142324432222235222222223223243262222222223142215232221223
3333336223432333433232224333433433543333133256432443333225433443122334323433233144344233321343334333
5276752595424547755633443385664543424854147528464348252547552254439224511942355486737692934729755533
3545445434524848473834544564533533544443748536454544472426773667244553544255444754454377447544474548
7754785884583737439724256838747637644436874474436148938376547746475473678457473536663447755565766346
3344423343434344123142445244322444434354215433363733444483142123534334332945442432335344313333344423
2232315225222244442225342263333623221127453252252332225344126232523452752162235475255272426242223484
5124342352712322136213673211223622242224341232232222642212547223247252268344322383522221423225383324
2112152511222522212242212222431232222232122222222242123222222212323212214212213212225222274332222212
2358536133134561546554344579333442145642357253937248432223352422323212255392266232284429436256539652
5534354234222243343123124324332233412244422227344434223313424322224222323124531222782232414322322232
2122452322163132222223263222223352215123223215421223431223234223323322422222322431224121323213222222
5988687788785775547857727647837554867656767415977688375476377753756566678767864687583587775463775427
3329324531334134832931653522432723733323545413243834431832512414335252353453413242114583232532432154
2532222421724322224323244422431197324612367244121222254243323416222382122422235444224632422322133421
3332223233411334322132234338343332333332132344332433332132231433232212331321323323233333532143333324
6682435538385848746983558647687676448557393346376775557823838782355455764554689848966445283878153934
4355654955552546643536545434754575435615478554185226643654254674225535512563653326257564224563335456
3333333411332344233233233335222222432223321523222744323234221532214323346232134522333374324225343124
3425222322234222132132222322213211345252232232322222231323212213223221326232232933132222222313282114
2222223222233222233241232322133222222233224222333331323223623352232212322313234332132223213123222223
2233233123831331526333243253333333253333281332253234333332343234323341333333713323333292233334313323
4556343454644445454444685754445334555686553552255654445756545333245554544546554452455546541335353533
4437142437348769764346723736355554789755533646855344785359265549925278742748321326453347655425464487
6334643334655433654235345144543743574434235243444546333356443335433545344431354234733635336235348343
2122212322242322322221424522242314322422242222212422212222212221221222222444212632242113242412422142
3247133333323422232322322313213349332433323341332345443624232333232332223313333431644333314364294333
3823222223322232322333327332233322233313243212242223233222232233323323162223123633232123223222322333
4222372222193245612422435623322432112225534326312222221362223222343324324262422421623336333193332332
2223232222222223232243231231222212132332222122232221232322232222222212222223332323222222212212231121
4243242323533263324524532233434224344453413433433244344334423333324335155324422522223332433344628423
3333313323631323333433222222223324132343333322343233322333242133433352513443325332321122223263223333
2222223252242422115233222353244223234223342225222343531213321412122124224224433232433126422453142333
2433122342342112233223232213242333233324233323323233342223332222332233322233223363333333222122333213
4644632653554444545534364373444367554344444735444733525537455733494446427853434315444534343436475234
1428224462633222477623242844261625122336225127353242424245822452326632542223434332672272423135615343
5352535366355445324444321365583732643533336333225333533833636365448454474442343533264323471324514573
3344422424434442232335334316322843323343126434442642322346443441343534442426436268333353324331133346
2228222222221211222222212222222123122222123232312323126222222122312322222731242222222332212212223322
5542633458433333458444866435543665114232423741474346622564352596325571548628782448539633233555134463
1222221124342222532224522423451344642232241522323221222122232222521422211262912553221222222812221642
5222226213136333254226233333236642323223525242212226532243132253233223511133262133213652323223123221
3231436336286233253431145233333352232333241321323353332243534632332333233223337312631632364632233332

13
day3/part1.py Normal file
View File

@@ -0,0 +1,13 @@
FILE = "input.txt"
def main():
return sum(max_for_line(line.strip()) for line in open(FILE))
def max_for_line(line: str) -> int:
tens = max(int(n) for n in line[:-1])
idx = line.index(str(tens))
ones = max(int(n) for n in line[idx+1:])
return tens * 10 + ones
if __name__ == "__main__":
print(main())

16
day3/part2.py Normal file
View File

@@ -0,0 +1,16 @@
FILE = "input.txt"
def main():
return sum(max_for_line(line.strip()) for line in open(FILE))
def max_for_line(line: str) -> int:
voltage = 0
for m in range(11, -1, -1):
part = line[:-m] if m > 0 else line
battery = max(int(n) for n in part)
line = line[line.index(str(battery))+1:]
voltage += battery * (10**m)
return voltage
if __name__ == "__main__":
print(main())

4
day3/test.txt Normal file
View File

@@ -0,0 +1,4 @@
987654321111111
811111111111119
234234234234278
818181911112111

139
day4/input.txt Normal file
View File

@@ -0,0 +1,139 @@
..@..@..@..@..@@..@@@@@@.@.@@@@.@.@@@..@.@@@.@@@.@@@.@@@.@.@.@@..@@@@@@@@@@.@@@..@@.@@@@..@@.@.@@..@@@@@@@@...@.@@.@@.@@@@.@@.@@......@@.@@
@@@@@@@@@@@..@.@@@@.@...@@.@@@.@@@@@@@@.@.@@...@@..@@..@@..@.@..@.@.@@..@.@@@@@@@@@@@.@@@@@@.@@.....@@@@..@@.@..@@@@@@@@.@.@.@@@...@@@.@@@@
.@@@.@@..@@@@.@.@..@@.....@....@@@@.@@@.@...@.@@.@.@@@@@@@@@@@@@@..@@@@@.@@@.@.@@...@@.@@.@@@@@..@..@@@@@@..@@@@...@@@.@.@@..@.@@@@.@.@@.@@
@...@@@.@@.@@@.@@@@.@@@.@@.@@@@@@@@@@@@@@.@@@..@@@@.@@@..@@@.@.@@.@.@.@@@..@@@@@@.@.@.@.@.@@@@@@@@@@@.@@@@.@...@@@@@@@@@@@.@@...@@@@@@@@...
@@@@.@.@@@.@..@.@@@@@@@@@@@@@@.@..@@@..@@@.@.@.@@@...@@@@@..@.@.@.@@@..@.@@...@..@.@....@@@@@.@..@@@.@@@@@@@@.@@.@@@.@..@.@@@@@@@@.@@.@@@..
@.@@.@@@@@@@@@@.@..@...@@@.@@@@@@.@.@@@@@.@@@.@@@...@..@.@.@.@@@@.@@.@.@@@@@@@..@@...@@@@@@@.@.@@@@.@@.@@..@@.@..@@.@@@.@@@@@.@@@..@@.@..@@
@.@@@...@.@@@@@..@@@@@@..@.....@@.@.@@@@...@@@.@@@.@@@@.@@@@@@@@@..@@@@@@..@@@@@..@@@@.@@@@@..@@.@...@..@@@..@@@.@@@.@@@.@.@..@@@.@@@@@@@.@
@@@@...@@.@@.@@@@@@....@@@@.@@.@@@@.@@.@@..@@@@@@.@.@@@.@..@@@@@@.@@@..@@@@@.@@@@..@..@.@@@.@@@..@@@.@@@@.@@@.@.....@@..@@@@.@..@.@@@@@@.@@
.......@@@@@@.@@@.@@@@@..@@.@@.@@.@@.@@@@.@@@@@..@@.@@@.@@.@.@@@.@@@@@.@@@.@@@..@.@.@@@@@@@.@@@.@@@@@@@.@@@@@@@.@@..@@@.@@.@@@.@@@@.@@@.@@@
..@..@.@@.@.@@@.@..@...@@@.@@@@@@.@@@.@@..@.@@.@@.@@@@@.@@@...@@@@@@@@@..@@@@.@.@.@...@@@@@@@..@@@.@@@@@@@.@@@@.@@@@.@@@@..@..@@.@.@.@@.@..
.@@@.@@@@@@@@@@@...@.@..@@@@@.@@@@@@@@@@@@.@.@@@..@@@@.@@@@.@.@@.@....@@@.@@..@@.@@..@@@...@@@.@@..@@.@@.@@.@@@@.@.@@.@@@.@@.@@..@.@..@...@
@@.@@@@@@@@@.@..@@.@..@@@@.@@.@@.@@...@.@......@@@@@@.@.@.@@@@@@@@..@...@.@@@.@@.@...@@..@.@@..@@.@.@.@@@.@..@@.@@.@@...@@...@.@@.@@@.@@@@@
@@@.@.@@@@@@.@@@@@@.@@@@.@..@..@@.@.@@@@.@@..@...@@@@@.@@@@@.@.....@...@@@@@.@@@.@@@.....@...@@@@.@.@@.@@.@@..@@.@@..@.@.@.@@@@@@@@...@@@.@
@..@@@@@@.@@@@@@@.@@@@@.@...@@@.@@.@.@@.@.@@@.@@.@.@@.@.@@..@@@@.@.....@@@.@.@@.@@..@@@@.@@@@@@@@@@@@.@.@.@..@@.@@@@.@@.@..@@.@@@@.@@@@.@.@
.@@@.@....@@.@@...@@..@@.@@@@@@.@@.@..@.@.......@.@@@@@.@.@@@@.@@...@@..@@@..@.@@@.@..@.@@@@@@..@@.@@@@@@@@@.@@..@@@.@@@@@..@@.@@..@.@@@@..
@@@@@....@.@.@.@@@@..@@@..@.@@@@.@.@@@@@@@@@...@@..@...@@@@@@@@.@.@@.@@.@@@@@@@.@.@@@@@@@@@@@.@..@@@@@.@.@@@.@@@@..@@..@..@@@@@.@@@@@...@@.
@..@@@.@@.@...@.@.@@@@@.@@....@@.@@@@..@...@.@@.@@@..@@.@@.@@@.@@@.@.@.@@@@@.@@@@@@@@.@@@@@@.@@.@..@@@@@@...@@@.@@@.@@@@.@.@.@@..@@@@@@..@.
@@@@@@@@@@@..@@.@...@.@@@@@@@.@.@.@@....@@@@.@.@@..@@..@@.@@@..@.@@@.@@.@.@@@@@.@@.@@@.@.@@.@.@@@@@.@@@...@@...@@.@@@.@.@@@.@.@@.@@.@.@@@.@
@.@@@@@..@@@@@@@@.@..@.@.@@@.@..@@.@@.@@@.@....@...@@@..@.@.@.@.@@@..@@@@.@.@@@@@@.@@.@..@@.@@@..@@.@.@@.@.@@@@.@@@@@@.@@....@.@@.@@@@.@@.@
@..@.@.@@@@@@@.@@@@@@@..@@@@.@@....@..@...@...@@.@@..@@@.@@@@..@@@@@@.@@@..@@@@@@@@@.@@@..@@@@@@@@@@@@@@@.@@@.@@.@@@@@@@..@@.@@...@@.@@.@.@
.@@.@..@@@@...@@..@@@@@..@@@@@@@.@...@@@...@@@....@..@@.@@@@@@....@@@@..@@.@.@@..@@@.@@@.@@@.@..@@..@.@@.@.@@@@.@.@.@@@@.@@.@....@..@@@.@@.
.@@@@@@.@@..@...@.@@.@@@@@@@@@@..@@@.@..@.@..@@.@.@@.@@@@..@@@@@@@....@@.@@.@@.@@@@.@.@.@@@@@@@@..@@.@@@.@@.@@@@..@@.@@.......@@@@@@..@@.@.
.@.@@@.@.@@@@@@@.@@@@@@@@@@@@..@@@@@..@.@@@@@@..@@.@.@.@@.@.@.@.@@@...@@.@@@@.@@.@.@@..@.@@@..@@@.@..@.@.@.@@@.@.@@@..@@..@@..@@@..@@@..@..
@@@@@..@@@.@@@@@@@@.@....@.@@.@@@@..@..@.@.@@@..@.@@@@@.@..@.@@@..@.@@@.@@.@.@@@.@..@@...@@@@@...@@@@@@.@@@@@@@.@@@@@@.@@.@@@@.@...@@..@@.@
@@.@.@@...@@@@@@@....@.@.@@.@@.@.@@@..@.@@@.@@.@...@@@.@..@@@@@@@@@@...@.@.@.@@@@..@@.@@.@@@@@@@@@.....@.@@@..@@@@.@@..@@..@.@...@.@@@.@.@@
@@@@@.@@@@@@.@@...@@@@@.@@@@@.@@...@.@@@@@@@.@..@@@.@.@.@@@@@...@..@..@.@.@.@@@..@.@@@@@..@@.@@.@..@@.@.@..@.@@@@@@@@@.@.@@@@..@@@@@@@@@..@
.@@.@@@@@@@@@@@@@@@@...@.@@@@.@@@@@@@@...@@@@@.@.@.@@@@.@@.@.@@@@....@@@@@...@@@.@@@.@@.@@@.@@.@@@@@@.@@@@@.@@..@@@..@@@@@@@..@@@@.@..@...@
@@.@@@@@@@.@.@@@@@@@.@@.@...@.@.@@@..@.@@..@@@@@@@@....@.@...@.@@@@@@.@@@..@.@@.@@@.@@@.@@@.@@@@@@@@.@@.@@@@@@@@@..@...@@@.@@@@@@@@@@@@@@@@
@@.@@@.@@@.@@.@@.@..@.@.@@@.@..@.@@@@@@.@@@@@@..@@.@@@.@@@@@@@.@@@.@.@..@..@.@@....@@.@.@@@...@@..@@..@..@@@@@@@@.@.@@@@@....@...@.@@.@@@@@
.@..@.@@@@@@@@.@.@@@@..@@@@.@@.@@@.@@@@@..@@@.@@..@@@@...@..@@@@.@@.@..@..@@@.@.@...@.@@.@@@@@..@@@@@@.@@.@@.@.@@.@@@.....@...@...@@.@@@@.@
@...@@.@@.@@@@@@@@@@@@.@.@@@....@@@@..@...@@@@..@@.@@@@.@.@@@@@@.@.@.@..@.@.@.@@@...@.@@.@@@@@..@@@..@@.@.@@.@@@.@...@.@@.@@@@@@...@@..@@@@
@.@@.@..@...@..@@@@.@@@@@@@@@.@....@.@.@@.@@@@.@@@@@@.@@.....@@@@@@@@@...@@......@@@.@@@.@.@@.@@@@@..@@@@@.@@@@..@@.@.@.@...@@..@...@..@@@@
@@.@.@@.@@@@@.@@@.@@@@@.@@.@.@@..@..@.@@@@.@.@....@..@@..@@@@.@@@@.@@@@@.@.@@@@...@@@..@@@..@@@@@@..@@@.@@@.@.@@@.@.@@@@@@...@.@.@@@@@@..@.
.@.@@@.@.@.@@...@@@@@@@@@..@.@@.@@@..@@@@@.@.@@@.@...@..@...@..@@@.@..@@@@@@..@@.@@@.@@@@@@@@@.@@@@@@@@@..@@@@@...@@.@.@@.@@.@.@@@..@..@.@@
@@@@..@@.@.....@@@@@@.@@@@...@.@@@@@@...@@@.@@..@.@@...@@@@@@@@@@.@..@@.@@@@.@@.@@@.@@@@@@.@.@.@@..@@@.@.@@.@@@@@@@@.@@@..@@@@@@@.@@.@@.@@@
@@..@@@@..@@.@@@..@@.@@.@@@@@...@@.@..@@@@..@@.@@@.@..@@.@@.@..@@@.@@@@@.@@.@.@@@@@.@@.@@..@@@@..@@..@@@@@.@@@@@@@@@@.......@.@@@@@@..@@@@.
@.@@@@.@@@@@.@@@@.@@.@@@@..@.@..@@@@@@@@.@@.@@.@@@.@@@@@.@@@.@@@@..@.@.@@@@..@.@...@.@.@@@@@@@.@...@@.@@@..@@.@@..@.@@@@@@.@..@@@@@@.@@@@.@
.@@@..@@@@.@@.@...@...@.@@@....@...@.@@@@@@@@@.@@.....@@..@@@@@@..@@.@...@@.@@....@@@@.@@@.@.@.@@.@@@@@@@@.@.@@@@@.@@@.@@@.@@.@@@@..@@@@@.@
@.......@.@@@@@@..@@@@@@.@@@@.@.@@@@..@.@@@@@@@.@@@.@@@@@.@.@@@@@..@@@@.@.@@.@@.@@@@@.@@@.@.@.@.@.@@@.@.@.@@..@.@@@..@@@@..@@@@.@.@@@..@...
@.@@@@@@@..@@..@@@@@@.@.@@..@.@...@@...@.@...@@@..@..@@@.@..@@@@@.@@@@@@@..@@@@@@@..@@.@@@..@..@.@@@@@..@@@.@@@@@..@@@@@@@@.@@.@@....@@..@@
...@@@@@@@.@.@..@@@@@@..@@@@@.@.@@@.@@.@@@@@@@@@..@@@.@@@.@@...@@@@@@@@.@@@..@@.@.@.@@@..@@@.@.@.@@.@...@.@@@@@@@@..@@@..@@@@@@.@@@@@@...@@
@..@.@@@.@....@@@@..@@..@.@@.@@.@...@@..@@@@..@@@.@@..@..@.@@@@@@@.@.@@....@@...@@@.@.@@@.@@@@@@@@.@@@..@.@@@.@@@@.@@@@@.@@@@@..@@..@@@@@@@
.@@.@@@@@@@@@@.@@@.@@..@@@@@@@@@..@@@..@@@@...@@@.@@@@@@@..@@@@@@.@@@.@@@....@@@@.@@@@...@..@@.@@.@@@@@@@@..@.@@@@@@@@@@@@.....@.@@.@@@..@.
@@@@@@..@.@@.@.@.@.@...@..@@@@.@.@.@@@..@@@@@@@@@@@.@@@@@@@@@..@.@.@@@.@@.@@.....@@..@@@..@.@.@@..@@@@@.@@@..@@@@@@.@@....@@.@@.@@.@@.@...@
@.@@..@.@@@@@@@@@..@@@@.@@@@@.@@.@@@..@.@@...@...@@@@@@.@@@@@@@@@.@..@@@@.@@@@...@@@@@@@@.@.@@..@@@@.@@@@@@.@.@@@..@@..@.@@@@@.@@@@.@@@@@@@
@.@@.@..@.@..@@@.@..@@@..@.@@@@@.@@.@.@.@@@.@...@@@@.@@@@@@@...@@@.@...@.@@@@@@@@@.@.@@@@@@@.@..@@.@@@@.@.@@..@@@@@@@.@.@@@@@......@@@@@@@.
@@@@@..@.@@@.@@.@..@.@..@@.@@@.....@.@@..@@.@@@@@@@@@@@@.@......@@@@..@.@@@@.@..@.@..@@@@@@.@@.@@@@.@@.@.@@..@@@@..@@@@@@@.@@..@.@@@.@@@...
..@.@..@@@@.@..@.@@@@@..@@@@@@@@@@@@.@.@.@@.@@@...@@@..@@...@@@@@..@.@@@@@@@@..@.@..@@@@@@@.@@@.@@..@.@@@.@....@@@@@@@.@@@@@..@@..@@@@@.@@.
..@..@..@.@@@@.@..@@@@.@.@@.@.@@@@....@@.@@.@.@@.@@@.@@....@@@..@.@@.@@.@..@@@@.@@@@@@.@..@....@..@@@@@@@.@..@..@@@.@.@@..@@@@@..@..@.@...@
@@@.@@@@@@@@@@..@....@.@@..@@@.@..@@@.@@@@@.@.@@.@@@.@.@@@..@@.@@@@..@@@@..@@@.@@..@@@@@@@.@@.@@@@@.@@@@@@@@....@.@@.@.@.@@@....@@@@@@@.@@.
@@@.@@@@@@@@.@@@@@.@.@.@@.@@@@@@@@@@@@@...@@@.@@...@@..@..@@..@@.@@..@.@@@@@.@@@@@@.....@.@@.@........@@@@@.@.@@@@@@@@@@.@@@...@..@@...@..@
@@...@@@.@...@@..@.@.@@.@.@...@@.@@...@@@@.@@@@.@..@..@.@.@..@@.@@@@@.@@.@.@.@@..@.@@@@.@.@..@@@@@..@..@.@@.@@@@@@...@@@@@@...@@..@@@.@.@@.
@@@@@@@@@....@..@@@..@@..@@.@@.@@@.@.@.@@@@@@@@@.@..@@@@..@.@@....@.@@@.@@@.@..@@@@@..@@@.@@@@....@@.@@.@.@@@.@@.@@@@.@..@.@@..@@@@@@..@@@@
.@.@.@.@..@.@@...@@@.@@@.@@@@@@@@@@@..@@@@@.@@@@.@@@@.@.@..@@.@@@@.@.@.@....@..@@@.@..@@.@@.@@.@@.@@.@@@.@.@@.@@.@@..@@@....@@.@.@@@@.@.@@.
@..@..@..@@@@@..@@.@..@@...@.@@.@.@@.@@@@@.@@@@@.@.@.@@@..@@.@..@@@..@@@@.@@@.@@.@@@@.@...@@@@@@..@@@..@..@@@.@@..@@..@@@@@@@@@.@@.@@@@@@..
@@@@.@@.@@@@@@@...@@@@@@@.@.@@.@@@.@@@.@@.@@@@...@@@@@@@.@.@@.@.@.@@@@@@.@@@@.@..@@@@@@.@@.@@@@@...@.@@@.@@.@@@@@@.@.@@.@@.@@@@@@@.@@@@@.@@
@@@@@@@....@@.@@@@@.@@@.@@..@..@.@.@@..@.@@@@..@@@@...@.@@@.@.@.@.@@@..@..@.@@.@@@@@@..@@@@@@@@@@.@@.@@@..@@@.@@.@@@@@@@@@@@@@@.@@@.@@.@@@@
@@@@@@.@..@..@@@.@.@.@@@..@@@.@@@@@..@@@@.@..@.@@.@.@@@@@..@@@.........@..@..@@@..@@@.@@@.@@@.@.@@..@.@.@@@@@@.@..@@@.@.@....@@@..@...@..@@
@@@@..@.@@@@@@.@.@@@@@@.@@@@@@@.@@..@@.@.@@.@@....@@@@@..@@@@@@@.@.@@@@@.@@.@@@.@@@@.@@@.@@.@.@@@.@.@@.@@...@@@@.@..@.@@@.@.@...@@@@@..@@@@
@@.@@@@@@@..@@@@.@@@@@@.@@@.@@@@.@.@.@.@@..@@@@@.@@@@@@@.@@.@.@@@..@..@.@@@@@@@@@@.@..@.@.@@@@@@.@@@@.@@@.@..@@@@@..@@@.@@@@...@@.@..@.@.@@
@@.@@..@@.@.@@@@@@..@@.@.@@@.@@@@@@..@@@@..@@@@.@@@@@@.@@@@.@@......@@@@@.@@.@.@@.@.@@.@.@....@.@@@@@@@@@@@@@@@@@@@.@.@@.@@..@@@...@.@...@@
@.@@.@.@.@.@.@@....@@@@@@@@...@.@.@@@@..@.@@.@@@@@.@@@..@@@@@@@....@@.@@@@@@@.@@@.@@.@@.@@.@@@@@@@.@@@@.@@@.@@@@...@@@@@.@.@.@.@@.@@@.@@@..
..@@@...@@.@@@...@@.@@.@@.@@..@@.@@@@@@.@@@@@@@@.@@@@@@@.@@@@@@@@@@@@@@@@@@@.@@@.@..@..@@@.@@.@@@@@@.@..@@@@.@@@@@..@@@...@.@@@.@@.@.@.@..@
@.@@@....@@@@@@@.@@.@@.@.@@..@.@@@@.@@@@@@@@@@@@@@@.@@..@@.@@@@@.@....@@@@.@@@@@@@@@.@@@@@@@@@..@.@@..@.@.@.@..@@..@@@@@..@.@.@@@@@@.@@@@@.
@..@@.@@@@@@@..@@@.@@.@@@.@.@@@.@@@@@@@@@@@@...@...@@@@@@.@....@..@.@@@@@@.@..@@@@@@@@...@..@@.@@@..@@@.@.@.@@@@...@@@.@@@...@@..@...@.@@@@
.@@..@..@@.@@@.@.@.@.@@.@@@.@@.@@@..@..@@.@@@.@.@@@@@.@@.@@@@@@.@@.@.@@..@.@.@.@@...@@@.@@.@.@.@.@@@@.@@@@@@@..@@@@@@@.@@@@@@..@.@@..@@.@@@
...@..@@@@@@.@@@..@@@@.@@.@@@...@@@@@.@@@@...@@@@@@@@@@@.@..@@@@@.@@@@@@@@@@@@.@@.@@@..@@.@@@@@.@..@@.@.@@@@@@.@.@@@@@@@@.@@@@.@..@..@..@..
.@.@.@..@.@.@@@@@@@@@@@@.@@.@@@@...@@@.@.@@@..@@@.@@@@...@@@@@.@....@@@@..@@@.@.@@..@@...@@@@@.@@.@@.@@@@.@.@@@@.@@.@@...@@@.@@@@.@.@@@@.@@
@.@..@.@.@..@..@@@..@.@@@@.@@@.@@@.@@.@@.@@@.@.@@@@@..@@@@.@@@@.@@@@@@@.@@@@@@.@@@..@@.@..@.@@@.@@...@.@@@.@.@..@....@@@.@@@@.@@@@.@@@@.@@@
@@@@@.@.@@@@.@@@@@@@@@@@@@@@@@@..@.@@....@@....@@@@.@@.@@@@@.@.@@@@...@@@@@@.@@..@@.@.@.@@@...@@@@@@..@@.@@.@@.@@.@@@@@@@@@.@@@.@.@@.@@@@@@
@@@.@....@@@@....@@.@..@.@.@.@@@....@@@.@@@.@@@@@@@@.@@@.@@.@.@@@.@@@@.@@@.@.@.@.@.@@.@.@..@.@.@@@@@@...@.@.@..@.@.@@@@@@@.@.@.@@@@@....@.@
@@@@...@.@..@..@..@.@@..@.@.@@@.@.@.@@@@.@.@..@...@@..@@@@.@@@.@...@@@@.@@@@.@.@.@.@@@@.@@@@@.@@.@@@@@@.@...@@.@@.@@@@.@.@@@@@@.@.@@@@..@.@
@.@.@...@..@@.@@..@@.@@@@@.@@@@@@@@@@@.@...@.@@@@.@@@.@...@@@@.@@@@@..@@.@.@@@@@...@.@.@@@@@@@@@@@@@@@@.@@@@..@.@....@.@..@@@@@.@@@.@@.@.@@
.@@..@.@.@@@..@@@@@@.@..@@@@@.@.@..@.@@@..@@@@@@@@.@.@@@@@.@@@.@@@@@@@@@@.@@.@@@.@@@@@@@@.@...@@@@@.@.@...@@@@@@.@@@.@.@..@.@@@@@@.@@.@@.@.
@@..@@.@@@@@@@.@@@@.@@@@..@@@..@@.@..@@@.@...@@...@@.@@@@.@@@@.@@@@.@@.@@@.@.@.@@..@@@..@..@@@.@@.@.@@@.@..@@.@@.@@@@@@..@..@@@.@@.@@@....@
@.@.@....@.@...@@@@@@.@@.@@@@.@.@.@@@@...@@@@@@.@@.@@.@@@@.@@.@@@@@@@@@.@@..@.@.@.@@@.@@@@.....@@..@@@@@.@@@..@.@@@@@@@.@.@@@.@.@@@....@@@.
@@..@..@@.@@.@@@@@....@@.@@.@@@.@@@.@...@@.@.@@.@.@.@.@..@.@@@@@..@.@.@..@@@@@@@@.@.@@@@@.@@@@@@..@.@..@....@.@@@@.@@@.@.@@@@.@@.@@.@@@@@@.
.@@@@@@.@@.@.@@@@@..@@.@@@..@@@@@@..@.@...@.@.@@@@.@@@@.@@.@@@@@@@@@..@..@@@@@@@@.@@.@@@..@.@.@@@@@.@.@.@@@.@@..@@.@@@@@.@@@.@@@.@@@.@..@@@
@@.@.@@@.@.@...@@@@@@@@...@@@@@@@@@.@@@@@.@@@.@@@@@..@@@..@@@.@@..@@@.@.@@@.@.@.@.@@@@@@.@@@@@.@@@@..@.@@@@@.@..@.@.@@@.@.@@@@@@@.@@.@@@@.@
.@@.@.@@@.@@@@@@@@.@.@...@.@@@@@@@@@@@@@.@.@.@@@@@@@.@@@@.@@.@@@.@@@@@@@@@@@@@@.@.@@@@...@.@.@..@@.@..@...@.@@.@@@@@@@..@@@@.@@@@@.@@..@@@@
..@@@@@@..@@.@.@.@@@@@..@@@@@.@@@@@.@@@@.@.@@@.@@.@@.@@@.@.@.@..@.@@...........@@@@@@@@..@@@..@@@.@.@@.@.@.@.@@@@@@@@@.@@@.@.@@.@@@..@@@.@@
@@@...@@..@.@@@@@@@..@..@@.@.@@@@.@@@@.@@@...@..@@@@@@@.@@..@@@@@@..@...@@@@@@@.@@@@@@@@..@@.@@@@.@@..@.@.@@@@.@.@...@@.@@@..@@@@@@@..@.@@@
@@.@@@@@@@.....@....@.@.@..@@@@.@.@@@@@.@.@@@..@.@.@@.@@.@@@@@.@@.@@.@@.@.@@@.@@@@@.@@@@@.@@@@@@..@@.@@.@@@@@.@..@@@@@@@@.@@@..@.@@@.@..@@@
@.@...@.@.@..@@@.@@@@@.@@....@..@@@@@..@.@@.@.@@@@...@.@..@@@@@@@.@@@@.@@@.@@@@.@@@@@@@@.@..@.@@.@@.@@@@@..@@@@.@@@@@@..@.@.@@@@@.@.@.@@.@.
@@.@@..@@@@@.@@..@.@..@@..@@@@@@@.@@@@@@.....@@..@@.@@.@.@@.@@@.@@@@.@@@@@@..@@@@.@@.@@@@@..@@.@.@@@@@@@@.@@..@@@@..@@..@@@@@@.@@@.@@.@@@@@
@@..@@@@..@.@@@@..@...@@.@@@@@@@@..@.@.@@@@@..@@@@.@.@@@..@@@@@@@@@@@@@@..@.@.@@@@@.@.@@...@@@@@@.@@@@@.@@@@@.@@@.@@..@.@@@..@..@@.@@@@@@@@
..@@@.@@@.@@@.@@.@@@.@@@@.@@@@...@.@.@.@.@.@@@@.@.@@@@@@@@@..@@.@@@@@@@@.@@@@.@.@.@@@.@@.@@@..@@..@@@@@@@@@@@@.@@...@..@.@@...@.@@.@.@.@@@.
..@@..@@@.@@.@@@@.@@.@@@...@.@@@@@@@.@@.@@@@@@@..@..@@@@.@@.@@.@@..@@@..@@@@...@@@.@@.@@@@@@@@.@@..@..@@@@.@@@@@@.@@.@@@@@@@@@.@..@..@.@.@.
.@..@@@@@@@.@.@@.@...@@@@@@@.@.@@@@@..@@..@@@@..@@@@@@@@@@@@@@.@..@@.@@@@@@.@.@@@@@.@@@@@.@@@@..@..@.@.@@..@@.@.@@..@.@@.@.@@@.@@@@@.@@..@@
@.@@@@@.@.@@@.@..@..@@.@@@@@@@...@.@@@@@..@.@..@.@.@..@@@...@@.@...@@@@.@@@@.@@@...@..@@.@@@@@@@@@@@.@@..@@.@@@@@@.@@.@@@...@.@..@@@@.@.@@@
@@@@@@@.@@@...@@.@@.@@@@.@.@@@@@@@@@@@.@@.@@..@@.@@@@@@...@@.@@@@..@@@@@@.@..@@...@@.@@@@@.@@@.@..@@@...@@..@@@.@@...@@....@@@@@@.@@@@.@@@.
...@@...@@....@.@.@@..@.@@@@@@..@@@@@@@.@....@.@@..@@@@..@@..@@@@@.@@@.@@@.@@..@@@@.@@@....@..@@@.@.@..@@@.@@.@@@.....@.@@@..@@.@@@.@@...@@
@@@.@@@@@.@@@.@@@.@@@@@@@....@@@@.@@...@@.@@..@@@.@@@@@..@@@@.@.@@@@..@..@...@@@@@@@@.@@@.@@....@@..@@..@@@...@@.@...@@@..@.@.@@@@.@.@@@@.@
@.@..@@.@@.@@.@@@@.@@@@..@.@.@.@..@@@@.@.@@@@.@.@@..@.@....@@...@@@@@@.@@@@@@@@@.@@.@@@@.@@@..@.@@@@.@.@@@.@...@..@..@@@@@@.@@.@@@@.@@@@.@@
@..@@@@.@.@@.@..@.@..@@@@..@@.@.@@@@@@@@@@@@@.@@@.@@@@@...@@@@@@@@@@.@@..@@.@@...@.@.@@@@@@@@.@.@..@@..@@..@..@@@@@@@@....@@@@.@@.@@.@@@@@@
@@.@@@....@..@@@.@.@@@@@@@.@.@..@@@@.@@@@@@@.@@@...@@.....@.@@@@@@@@@..@.@@@..@@...@@@@.@@@..@..@@.@@@@.@@.....@..@@@@@.@@....@@@..@@@.@@.@
@@@@.@@@@@@.@@.@@.@@@.@@@.@@@.@@@@...@.@.@@@@@@.@.@@@@@@@@@@.@.@.@...@@@@.@.@@@...@@..@@@.@@@@@@@....@@@@.@.@@@@@@@@@@@.@@@..@@@@@.@.@@@...
@@@@@@@@@.@......@@@..@@@.@.@@@@..@@@.@@@.@@@.@@@@@@.@@@.@@@@.@.@@@@@..@@@....@.@@.@@@...@.@@.@@.@@@.@@@@@..@@@@@.@@@@.@@@@@@@@.@..@@...@.@
.@.@..@@@@.@@.@@.@@@..@@@@@@@@@@@.@@@.@@.@..@.@@@@@.@@@@...@@@.@@@@@@......@.@@@..@@@...@@..@.@@@.@@@.@@@@...@.@.@.@..@..@@@..@@@.@.@@.@@@@
@@@@.@@@.@@.@@.@@@.@.@.@@@.@...@@@.@.@@@@@..@@@@..@.@@....@@@@@@@@@..@@....@@@@.@@@@.@.@@@@@@@@.@@..@.@@...@.@@@.@..@@@@@@..@.@@@.@@@@@..@.
@@@..@@@@@@.@@.@@@.@..@@@@..@@@@.@.@@@@@.@@@@@@@@.@@@.@..@.@@@@.@@@@@@@@@@@@@.@@@@@.@.....@@@..@..@@..@@..@.@@@..@.@.@@@@@.@@@.@..@@....@@.
@@@@@...@....@@@@@.@@@@..@@@.@@@.@@.@@...@@.@@@@@@@@@@..@@@.@.@.@@@@@@@@@.@@.@@@@@.@@.@@.@.@@..@@@@@@@@..@@@@@..@@@@..@@@.@.@@.@@.@.@@.@@.@
@@@@.@@@@@@@@.@@..@.@@@@.@@@.@@@@.@.@.@.@@@@@..@.@@@@@@...@@@@@@@@.@.@.@@.@@@..@@..@..@@@@@@@@..@@@@@@@..@@@@@@@.@@@@@.@@@@@@.@.@.@.@@@..@@
@@.@@@@.@@@@.@..@@@@@@@@@@@@..@@@@@@@.@.@@..@..@.@@@@@@@@@@.@@@@..@.@@@@@@.@.@@.@@@@.@@@.@@..@@@...@.@@@.@@@@@.@@@@@@@@@@..@@.@@..@@..@@@@@
@@@..@.@@.@@@.@..@.@......@@@..@@@@@.@@@@@@.@@@.@@..@@.@.@@..@...@.@@@@@@@@@@@@@.@@@@@.@...@@@@@@@@.@@..@@@@.@.@@@@@..@.@..@@@.@@@@@@@..@.@
@@@.@@..@@@@@.@..@@@.@.@@@.@@@@@..@..@........@@@.@.@@@@@@@@@...@@@.@@@@.@.....@@@.@..@@.....@.@..@@@@@.@@@@@.@.@.@@@..@@@@.@@@@.@.@@@.@..@
.....@@.@.@..@@@@@@@.@@.@@@.@@.@@@.@.@@@@.......@.@@@.@..@@@.@.@@@@@@@@..@@@.@..@@@@@@@...@@.@@@@@@.@@@@@@@@.@@@@...@@@@@.@@@@@...@@@@.@.@@
.@@@@....@@.@.@@@.@.@@@.@@@.@@@.@@@.@@@@.@@@@@@@@@@@@@.@@@@@.@@@@@.@@@.@@@@@@@@.@..@..@.@...@@.@@@@@@@.@.@..@@@@..@..@@.@@@@@@@.@@@.@@@@.@.
@@@@.@@@@...@@..@@@@@@@@..@.@@@@..@@.@@..@@@.@.@.@..@@@@.@.@@@.@.@@@@@@.@.@@@@@@@@@.@.@.@@.@@@@@.@@@@@@.@@@@@@.@@..@@@@@@..@@@@@@@@@.@@@.@@
@.@@@@.@@@.@@@.@@..@@@@@.@.@@@@@.@@.@@...@@....@@@@.@@@@@@@...@.@@@@.@.@.@.@.@.@...@@.@@@@.@@..@.@...@@.@@@@@@@@@.@@@.@.@....@.@..@@@..@@..
.@@@@@@..@..@@@.@@@.@@...@@.@.@@@@.@@@@@..@.@.@@.@@@..@@@@@@@@@@@@..@@..@@.@@@@@.@@@..@@@@@@@@@.@@@.@...@.@@.@.@...@.@..@@@@.@.@@@.@@@.@.@.
@@@@..@@@.@.@.@.@@@.@@@..@@@....@@.@@..@..@@.@.@.@@.@@@@@.@@@@@@@@@@@@..@.@.@..@.@.@..@@.@@...@@.@@.@@...@..@@.@@.@@@.@@@@@@@@@@.@@@.@@@@@@
@@@@@..@@@..@@..@.@@..@..@.@.@@...@@.@..@@@@.@@@@....@@@@.@.@@..@@@@..@@.@@..@.@.@...@@@.@@@..@@@.@.@.@.@..@@@@.@@.@..@...@@@@@@@@@.@.@@.@.
@@@@@..@...@@@.@@@@.@.@.@@@.@@@...@@@.@.@@@@@.@@..@@.@@.@.@@@@@.@@.@@@@@@@@@@@@.@@@.@...@..@...@.@@@.@.@.@@@@@@@.@@@...@@@.@.@@@@@.@@..@.@.
.....@@@@@@@.@@@@.@@@@@..@@@.@.@.@@...@..@..@.@..@....@@@@@@@..@@..@..@.@@.@@@@.@.@@.@..@.....@@@@@@@..@.@@@@@@@@.@.@@@@...@@.@@.@@.@.@@..@
@..@@@.@@@@@.@@.@@@.@@@@.@@@@.....@@@...@.@@@@.@@@@@@.@@@@.@@.@@@@@@.@@.@.@..@@@@@.@@@.@@@@@...@.@@@@.....@@..@@@.@.@.@@@@@@@@@.@@..@.@..@@
.@@@..@..@..@@..@..@@@@@@@...@@@.@@.@@.@..@@@..@@@.@.@.@@@@@@@@@@...@@@.@.@@@@@.@..@@@@..@@.@@@@@@.@.@.@.@@@@@@@@@@@.@@@@@@@@@@@..@@.@@@...
@.@..@@.@@.@@.@@@@@@@@@@..@.@@@@@.@@..@..@.@@@@..@@@.@@@.@@@@@@.@.@...@@@@.@.@..@@@@@@@@.@@@@@.@@@@.@.@@@@@@@.@@.@@...@@@@@@@@....@@@@@@@@.
@@@@@..@.@@@.@@.@@@@@@@@.@.@...@@@@@.@@.@.@@@.@.@.@.@@@@@.@@.@.@@.@.@.@..@@.@@@@@@@@.@.@@@@@@@@....@...@@.@@@@@@..@@@@@.@@.@.@.@.@@.@.@@@..
..@.@@@.@...@@@.@@.@@@@@@@@.@...@@@.@@@.@@.@.@.@.@.@.@@.@@.@..@.@@@...@@@@@@@.@@@@@@@@..@.@.@@@.@.@@.@..@....@@@......@@.@@..@.@@.@@..@..@.
.@@@.@@@.@..@@@@@@.@..@.@.@.@@.@@@.@..@.@@.@@@.@.@@..@@@@@..@.@@@@.@.@@.@..@@.@@@..@@.....@..@@@..@.@.@.@..@.@.@.@..@.@@.@@.@@@..@..@@@@@.@
@@.@@.@@..@@@@@@.@@@@@@.@.@.@@.@.@@@...@...@@...@.@@@@@@.@.@@.@@@..@@.@.@@@@@.@..@@@@@@.@.@.@@@..@.@@.@.@.@@.@@@@.@@@@@.@..@@@@@@@@@.@..@.@
@@@@@@@@@..@.@..@@..@@@@@...@@@@@.@@.@@@@@@@...@...@..@.@@@.@....@@@@@.@@@@@@@@.@@.@@@@@@.@@.@...@.@@..@@...@@@@.@@@@@@@.@@@@@@..@.@@@...@@
@.@@..@@@...@.@@.@@@@@..@.@@@@@@@.@@@@@..@@.@@@.@..@@@@@@@.@@@@@@@..@.@.@.@..@@.@@@@.@@@@.@@@@@@@@@@.@@.@@@@@@@@.@@@@@@@@@.@@@@..@@@@@..@@@
@@@@@.@...@.@@@@.@@@.@@.@@@.@@.@.@...@@@@@@...@@@@...@..@@..@.@.@@@.@@@@@@@@...@@@@@@@..@@@@@@@@.@@@@@@@.@@@..@@@@@@@...@.@@@.@@@@@@@@.@@@@
.@@.@@..@.@@@@@.@..@@.@@@@...@@@@@.@@@.@.@.@.@@@@@.@@.@...@.@@@@.@.@@@@.@@@@@.@..@.@.@@@@@@@.@@.@.@@@...@.@@@@.@..@..@.@@@@.@..@@@@@@.@@@.@
@@@.@..@@.@@@@.@@@...@.@.@@@.@@@@@@@.@@.@@...@@@@@@@@.@@@@@..@@@..@@@..@@@.@..@@@@..@@.@@.@@@@@@@.@@@@.@@.@.@.@@@@@.@@@@.@@..@@@.@@@@@@@.@@
.@@.@@@...@.@@@.@@@..@..@..@@.@@@@...@..@@..@@..@.@@.@@@@.@.@@.@.@@@.@..@@@@@.@@@@@..@.@..@.@@..@.@..@..@.@@@@@@@@.@@.@@@@@@@.@@.@@...@@.@@
@@.@@@..@@@..@..@@.@.@..@@@.@@.@@@@.@@.@@@.@.@@@.@@.@.@@@@.@.@..@@@...@@@@@....@.@@.@@.@@@@@@@@@.@@@@.@@.@.@.@.@@@@@@@@@.@.@@@@@.@.@@@@@..@
.@@@@.@...@.@@@...@@.@.....@@.@@...@@@@@..@@@..@@.@..@@@@@@@.@.@@.@.@@@@.@.@@@@@.@@..@....@...@@..@@@...@@@@@@..@..@@@@@...@@@@@.....@@.@@@
@..@.@@.@@@....@@@@.@@@@@@@@@..@.@@@..@@@@.@@@@@@@@@@@.@..@@@.@.@.@..@@..@@....@@@..@..@.@@.@@@.@...@@..@@.@@@@@....@@.@@@@.@@.@@@@@@...@@.
.@@..@@..@@@@@@....@@.@..@@.@@@.@@@@@.@@@@...@....@@.@@@.@..@@.@.@.....@@@@@@.@@.@@@@@..@..@@@@.@@@.@..@@..@@@@..@.@@@..@@@@@.@.@@.@@.@@@@@
@@@@@@@@@..@.@..@@@.@@@.@.@@@@@..@@@..@@@@@@..@@@@....@@.@.@.@...@.@@.@@@@.@.@@.@@@.@.@@..@@@@.@@....@@@...@@..@@@@@@...@.@@@@.@@.@@@@....@
.@@.@.@@@.@.@@.@@..@..@@@@.@@.@.@.@..@@.@..@@@@@@@..@@@@@.@.@@.......@@@@@@..@.@@@.@.@@..@...@...@@@@@.@.@@@@@@@@.@@@@@.@.@@@@@@@@@@@@@@@@.
.@@@.@@@@.@@..@@@@@.@@.@@.@@@..@.@.@@.@@..@@@@@@.@@@@@@@@@..@@@@@.@@@.@@@@@..@@@@@@@@@@.@.@@.@@.@@@.@@@@@@@@...@......@...@@@@.@@.@@@@@..@@
.......@@@@@..@.@.@@@@@.@@..@@@@@@...@@@..@@.....@@@.@@.@@@@.@@.@@@@@@@@.@.@.@@@@.@@@.@@@@@@@@@.@@..@.@.@....@@@@@@@@@@@..@@.@@@.@@..@@..@@
.@@@@@@.@@@...@.@@@@.@..@@@@@@@.@.@@......@@@@@@@@.@...@@..@.....@@@@.@@..@@@@@......@.@.@.@.@@.@..@.@@@@@.@.@@@@@@@@@...@.@@..@@@..@..@...
@@.@@.@@@@@@@@.@@.@.@@.@@@@@@@@@@..@.@@@@.@@@@@@@@@@@..@.@.@@@@@@@@@@@@@@@@..@.@@.@.@@.@.@@@@.@@@@..@.@@.@@.@..@@@@.@@@@@..@@...@@@@@@.@@..
@@@...@@.@@@@@@@@.@@@.@@@..@@@@..@@..@@.@..@@@@@..@@.@.@@@.@@@..@@..@@.@@@...@@@@.@@@.@@@@@@.@@.@@.@..@@@@.@@...@@@..@@.@@..@.@@@@.@@@@.@@@

28
day4/part1.py Normal file
View File

@@ -0,0 +1,28 @@
FILE = "input.txt"
options = [
(-1, -1), (-1, 0), (0, -1), (1, 1), (1, 0), (0, 1), (-1, 1), (1, -1)
]
def main():
accessible = 0
grid = [list(line.strip()) for line in open(FILE)]
for i in range(len(grid)):
for j in range(len(grid[0])):
if grid[i][j] != '@': continue
nearby = [
(i + x, j + y)
for (x, y) in options
if 0 <= i+x < len(grid) and 0 <= j+y < len(grid[0])
]
nearbyRolls = [
grid[x][y]
for (x, y) in nearby
if grid[x][y] == '@'
]
if len(nearbyRolls) < 4: accessible += 1
return accessible
if __name__ == "__main__":
print(main())

37
day4/part2.py Normal file
View File

@@ -0,0 +1,37 @@
FILE = "input.txt"
options = [
(-1, -1), (-1, 0), (0, -1), (1, 1), (1, 0), (0, 1), (-1, 1), (1, -1)
]
def main():
total = 0
grid = [list(line.strip()) for line in open(FILE)]
while True:
accessible, grid = removal_loop(grid)
if accessible == 0: break
total += accessible
return total
def removal_loop(grid: list[list[str]]) -> tuple[int, list[list[str]]]:
accessible = 0
for i in range(len(grid)):
for j in range(len(grid[0])):
if grid[i][j] != '@': continue
nearby = [
(i + x, j + y)
for (x, y) in options
if 0 <= i+x < len(grid) and 0 <= j+y < len(grid[0])
]
nearbyRolls = [
grid[x][y]
for (x, y) in nearby
if grid[x][y] == '@'
]
if len(nearbyRolls) < 4:
accessible += 1
grid[i][j] = '.'
return accessible, grid
if __name__ == "__main__":
print(main())

10
day4/test.txt Normal file
View File

@@ -0,0 +1,10 @@
..@@.@@@@.
@@@.@.@.@@
@@@@@.@.@@
@.@@@@..@.
@@.@@@@.@@
.@@@@@@@.@
.@.@.@.@@@
@.@@@.@@@@
.@@@@@@@@.
@.@.@@@.@.

1172
day5/input.txt Normal file

File diff suppressed because it is too large Load Diff

27
day5/part1.py Normal file
View File

@@ -0,0 +1,27 @@
FILE = "input.txt"
def main():
freshRanges = []
indgredients = []
complete = False
for line in open(FILE):
if line == "\n":
complete = True
continue
if not complete:
freshRanges.append(line.strip().split("-"))
else:
indgredients.append(line.strip())
freshRanges = [
range(int(start), int(stop)+1) for (start, stop) in freshRanges
]
indgredients = [ int(x) for x in indgredients ]
return len([
indgredient
for indgredient in indgredients
if any(indgredient in r for r in freshRanges)
])
if __name__ == "__main__":
print(main())

22
day5/part2.py Normal file
View File

@@ -0,0 +1,22 @@
FILE = "input.txt"
def main():
ranges = []
for line in open(FILE):
if line == "\n": break
ranges.append(line.strip().split("-"))
ranges = sorted([
(int(start), int(stop)+1) for (start, stop) in ranges
], key=lambda x: x[0])
condensed = [ranges[0]]
for r in ranges:
end = condensed[-1][1]
if r[0] <= end < r[1]:
condensed[-1] = (condensed[-1][0], r[1])
elif end < r[0]:
condensed.append(r)
return sum(len(range(r[0], r[1])) for r in condensed)
if __name__ == "__main__":
print(main())

11
day5/test.txt Normal file
View File

@@ -0,0 +1,11 @@
3-5
10-14
16-20
12-18
1
5
8
11
17
32

5
day6/input.txt Normal file
View File

@@ -0,0 +1,5 @@
155 1 62 1925 984 83 723 832 57 1 134 44 6 55 95 4 3 4146 88 7 63 249 6 79 933 87 829 3 89 533 99 5575 38 27 9729 8 5495 74 8115 6 291 13 7 52 427 85 8 63 18 61 37 14 83 49 6 52 846 46 8 7 3 349 134 8 74 4 641 4649 89 88 63 31 53 87 166 1266 87 75 8698 27 199 21 5 794 84 293 882 33 7 48 54 62 51 49 16 73 37 5 27 47 85 869 1 772 83 48 5 12 6941 29 71 12 2 7 64 7 97 61 2314 856 1 3 557 16 84 32 249 35 2 262 355 8177 956 225 167 122 68 16 53 63 31 8 46 122 976 698 4 45 66 7235 7443 17 7366 32 2288 45 398 495 74 45 885 51 28 9 21 39 513 16 353 9 12 414 9 77 413 953 2 3 4 644 52 81 1637 6 43 7 69 9 511 47 937 27 593 7 2 56 749 46 152 4 12 25 6574 686 89 528 838 81 56 3 81 77 44 254 8 427 475 921 386 2338 2 6114 2 35 445 871 698 4 64 52 23 81 12 39 4172 3 16 14 213 48 47 9 54 33 5 9485 82 614 427 36 45 74 2 48 378 9 291 4 75 741 545 6 15 939 2 6358 2315 3418 531 97 21 23 355 36 2873 62 55 54 88 92 73 44 87 2792 9 79 523 34 29 86 7 388 4153 8 96 9 19 1 27 713 3 4 85 253 661 49 181 71 61 7 74 12 744 948 8 565 42 83 76 163 28 63 6835 32 4597 34 781 721 87 391 633 3 6466 3554 394 43 686 6 33 53 1 4114 788 434 41 31 726 8 4 837 7 264 46 1 27 89 8 298 5 29 191 76 3 377 45 3 15 5 3 62 58 1138 839 7 55 2 191 29 2 646 38 68 29 3 3233 84 658 84 828 757 6 47 416 96 671 56 732 51 68 92 2 124 915 27 4666 2 63 962 895 1 214 771 27 6111 4832 1 4 91 3 38 4878 44 8391 8748 354 23 79 72 9 6 839 13 2 15 7 32 835 455 72 4 319 9441 44 94 58 7 266 272 71 99 1369 63 31 67 989 2 99 3 876 333 45 8 752 9 3 996 5 64 67 62 1 746 43 752 154 9 471 689 113 817 8 898 924 42 1 74 1432 36 756 42 37 5 4 67 82 293 76 215 54 44 6 7 88 15 49 29 233 88 18 31 746 512 118 34 8 843 7785 411 38 675 19 75 39 97 9 255 7 942 88 1 462 1 483 814 513 438 98 89 381 963 3 46 67 983 247 292 91 668 8 31 265 647 2789 8519 91 66 246 918 47 68 931 2 684 862 8 278 611 84 7554 357 92 1276 239 785 497 79 696 719 1139 9 588 685 23 8 91 97 12 56 1681 589 6936 19 795 781 88 31 68 63 921 466 32 5 41 828 743 743 72 61 9 847 98 9742 46 485 3 85 33 54 65 8744 58 486 964 86 656 96 98 232 276 35 957 19 332 3571 146 73 93 9 952 23 89 41 91 5992 459 481 9 94 84 87 559 43 383 3 25 882 84 292 2 59 28 35 843 944 14 27 54 4 7 924 1 9946 785 676 8996 1 57 43 2 14 8239 885 142 5383 48 429 32 593 49 5866 95 34 9 166 926 34 76 48 1 94 19 72 4 45 64 47 339 94 8 66 99 21 2114 32 56 416 91 7213 665 22 333 95 6695 827 325 993 68 84 17 79 3 113 851 472 874 2798 1 5871 411 9 27 97 6829 87 453 56 2346 96 53 16 52 7 9 15 63 76 476 45 438 25 88 2 61 4 36 28 32 277 1 7 31 288 566 97 24 19 1671 297 539 25 24 2 9 1711 9 19 1 15 853 8 7122 89 491 57 32 156 45 742 18 587 773 6 752 5 2225 413 214 786 3 2 363 2957 6 2 797 6773 6715 2666 151 51 3 9 82 759 78 882 7523 75 3691 163 14 989 146 6 4 44 746 6 3 66 651 7 74 17 6688 75 954 574 9 8 224 5 61 7443 59 658 264 73 83 69 23 66 742 2 94 479 58 4426 854 8397 86 6 11 2931 9 7 2 561 73 82 472 443 65 45 5 89 1326 651 791 92 9416 16 91 2692 58 978 1469 151 85 49 6 477 34 18 66 9569 6 92 197 127 15 9 66 9 8239 61 98 98 51 39 59 43 535 1 39 3 25 789 52 2 2 912 88 92 644 8446 71 57 3 27 698 26 3 38 1 158 768 4367 8 48 5 9 9388 57 2 357 4 26 588 3 59 81 43 8 893 522 746 93 37 3 778 94 536 76 3 25 32 26 31 447 66 27 68 1 27 32 44 659 13 27 7 85 5542 454 3 92 761 79 832 5
614 4 39 3446 379 675 574 352 75 58 447 52 285 39 987 4 97 4371 22 177 14 563 53 43 459 94 161 163 94 184 448 4583 91 63 15 75 1232 19 8224 8 498 75 3734 595 885 268 14 26 33 595 76 72 19 52 13 12 263 41 1 25 1 327 224 65 76 86 932 6212 15 49 87 27 57 87 575 6337 85 31 3466 626 397 87 27 675 81 962 645 69 86 33 61 54 23 44 51 67 67 9 91 98 78 952 699 666 88 914 44 44 4963 33 117 75 8 8 13 13 72 47 2249 465 2 19 364 67 99 576 738 72 23 637 755 3435 695 468 125 112 98 796 59 42 17 1 78 683 957 3472 448 12 451 244 2312 32 8689 83 4796 72 391 882 66 55 568 23 266 95 47 28 256 16 295 69 68 7558 378 97 469 816 95 493 24 329 32 66 2668 94 66 5 23 69 1 2 946 88 214 85 97 46 939 18 544 95 23 91 589 122 6 673 597 46 52 93 12 8 686 569 93 934 111 681 179 9571 9 3744 4 47 298 451 793 775 98 98 28 29 42 69 1792 96 922 14 194 22 86 618 644 13 823 4372 68 716 239 42 71 38 4 61 444 22 388 3 37 314 315 96 24 119 32 1628 2667 11 848 29 274 48 945 16 5492 34 52 46 74 16 61 235 86 466 3 11 963 95 93 55 822 185 6644 55 21 851 77 1 8 564 4 39 12 552 1796 95 66 287 25 92 93 21 618 589 6 881 1627 88 47 822 95 78 667 8 5955 75 87 638 69 787 148 56 6573 7572 455 45 462 91 57 5 57 7872 484 748 64 7 851 41 362 796 77 842 12 6 689 91 4 16 85 66 391 2994 92 6792 83 6 44 31 25 56 14 1333 871 32 4 67 525 1288 47 535 87 31 73 19 5275 6454 518 71 6456 587 56 89 821 71 86 55 554 75 23 24 62 851 457 16 2615 79 37 424 368 82 397 952 25 2268 177 41 343 5 5 6638 6142 53 2132 2317 36 95 56 83 37 58 853 39 22 11 1493 639 627 785 969 7 498 9774 93 43 46 43 749 162 537 8822 8739 35 99 66 619 6 77 1 734 293 23 26 41 27 36 467 36 52 97 816 289 99 71 435 797 849 334 939 937 815 59 687 598 14 61 745 7882 51 649 764 54 84 9 52 952 481 762 135 52 962 9 33 55 97 56 39 81 22 97 367 5167 973 749 42 355 553 1593 519 97 784 869 94 88 52 4 468 38 991 63 41 334 9 916 983 825 819 18 8275 85 611 732 15 57 5863 6836 999 158 972 33 13 3647 56 6958 382 55 78 219 953 57 29 27 216 222 817 16 56 946 87 3396 146 63 8627 538 381 486 882 541 1524 2151 8 894 8578 962 4 94 59 14 47 4311 541 1584 6188 725 584 99 64 35 449 71 72 153 611 4 3577 624 245 77 15 64 996 9153 1685 478 592 7 51 63 431 754 688 18 46 871 78 1394 349 23 312 985 95 774 619 285 3296 292 88 28 41 522 158 8 28 26 3258 512 167 77 744 79 783 855 13 592 73 22 687 68 524 52 33 98 19 463 246 129 26 13 2 23 726 52 7159 456 686 6644 1 42 7 1 46 9261 711 483 1189 1 85 73 969 13 6842 96 457 1 712 422 81 29 25 69 56 47 678 64 18 75 65 83 428 782 36 49 59 2276 35 22 228 96 994 868 48 976 22 445 336 779 217 247 3547 11 185 38 824 251 814 2615 3955 91 4265 887 565 996 44 8825 827 158 99 7714 312 67 52 19 56 84 97 73 61 778 41 839 37 58 84 24 49 32 62 77 234 598 27 33 171 248 46 68 79 8345 133 988 11 32 16 9 4818 14 516 79 71 811 9 7833 983 178 55 46 44 25 946 443 638 921 42 167 34 2221 429 235 287 78 16 63 4143 84 82 617 7873 5813 2232 989 174 4 48 74 346 37 724 3461 27 22 667 94 717 973 441 92 74 399 5 8 26 592 17 62 46 7832 722 955 345 97 93 73 7 41 3271 22 881 653 67 37 86 6 82 574 19 59 11 725 1337 466 485 36 3 82 8113 3 511 5 742 9 19 968 92 545 81 37 8 1284 586 976 5147 6262 481 36 8151 83 191 5519 935 414 47 39 267 442 37 34 7176 7 879 494 728 4 12 39 62 8296 89 5879 56 93 36 46 35 547 253 96 5 73 275 48 88 12 684 21 84 7356 7291 627 76 43 58 454 29 7149 42 28 624 6431 5172 98 99 1 1 53 9238 72 372 22 16 479 13 3 63 69 66 37 35 587 468 225 13 837 9 834 976 34 26 16 56 24 444 44 11 89 7 31 8 16 646 397 323 45 91 715 261 845 47 795 49 582 4
89 3 85 486 42 855 95 654 776 32 163 36 348 92 131 22 95 866 3 269 44 9 591 45 41 144 142 959 36 576 576 227 3 68 8 49 8515 37 9552 51 579 62 1535 511 248 4778 76 66 71 267 62 11 78 421 973 451 549 36 43 48 246 41 39 29 626 355 715 4545 78 74 15 52 28 16 541 2744 394 65 5927 9843 632 51 36 89 51 18 846 37 136 34 67 91 648 81 41 27 59 3 571 9136 5 445 996 831 34 168 686 31 146 95 169 2 62 45 31 698 67 68 581 978 86 664 865 88 34 2139 776 9 64 929 547 223 4798 5 1377 443 43 412 33 43 81 81 19 271 62 5836 298 34 465 29 9846 3 9678 68 666 61 69 1395 47 3 552 2 562 35 521 23 231 74 8 4161 17 7727 546 84 514 535 55 725 63 454 6 13 6545 729 59 93 44 94 4 7 125 25 515 9781 34 2 886 997 352 67 15 49 853 754 5 724 433 6 6 99 7 3 157 934 84 293 73 185 52 671 5 1263 82 84 218 135 351 474 3 25 91 7 52 78 9823 65 845 44 477 99 37 1154 253 27 774 594 51 677 691 5 29 74 72 38 285 39 63 17 49 286 171 825 497 36 133 113 44 32 394 47 157 47 15 481 366 98 65 72 27 24 27 658 66 83 8 79 876 4 12 83 681 78 92 4141 98 919 96 42 2 766 31 96 33 754 6267 38 35 9556 64 25 61 29 655 54 49 236 9918 42 46 295 58 976 69 5 5396 58 17 475 8 212 674 23 298 2235 85 69 423 18 2577 4 17 168 471 99 24 1 47 343 214 497 44 1828 9 561 349 64 4 16 56 92 197 6283 47 1444 47 19 49 64 73 87 99 4568 9 17 3 14 61 1279 531 573 33 25 17 93 7166 3879 579 94 3155 837 87 57 619 63 23 4223 315 49 46 37 1753 2 581 11 8372 92 14 124 32 39 628 75 42 4348 89 785 785 3 95 6642 4818 88 662 4934 56 38 86 53 23 98 7 85 14 876 8168 375 59 992 953 28 367 118 81 23 2 68 156 26 9779 8195 2925 97 7 32 68 8 62 88 423 144 33 55 98 43 526 4 915 4 56 8836 746 3 1 66 193 975 922 413 611 846 41 74 113 82 121 291 9614 813 976 995 46 563 93 91 894 828 562 3642 1 378 4 93 773 39 6346 81 6 69 62 647 3884 989 919 196 927 888 2349 4491 716 92 444 29 621 116 89 48 27 158 521 76 371 6 59 892 854 4994 49 2878 61 791 541 26 8 7282 2851 2368 312 518 52 94 6377 5 2816 1 41 597 276 57 81 4 5 239 136 95 7257 91 184 31 119 697 35 7196 221 694 24 616 762 7652 1822 9 75 5544 354 66 26 378 69 87 13 664 867 1595 277 522 14 37 51 967 1 59 676 666 7 7339 545 6 96 62 2421 747 6675 9358 762 36 4 81 18 452 166 17 96 59 784 65 1825 331 74 98 71 42 131 929 65 7228 7 18 26 933 236 135 2 95 184 88 36 382 37 333 6 598 434 924 442 853 8 781 49 195 14 37 49 86 197 95 537 94 6 94 66 95 72 9726 948 51 47 93 45 4 15 64 2122 629 981 746 1 25 13 554 83 875 863 1468 8 5 899 372 35 3 32 48 67 239 65 97 71 94 85 565 592 61 62 87 5374 86 897 925 73 853 653 38 1 79 288 189 126 21 1819 8615 3 942 49 619 644 118 3835 8351 191 5639 657 438 471 582 7849 938 395 41 3716 461 442 36 1 511 51 3 9 27 551 3 313 86 5 79 99 568 76 45 63 96 1663 81 3 441 476 96 6782 69 7 184 45 47 61 954 84 4732 64 761 34 69 247 4 2943 111 354 262 89 63 44 29 7496 541 51 25 869 71 563 12 538 39 84 52 98 6486 19 428 163 6367 8336 113 65 556 37 75 89 92 92 392 4183 45 21 388 925 239 23 381 628 7 672 51 261 38 582 54 5 44 51 4841 75 152 421 48 6 6 56 828 78 369 962 71 57 83 1 92 763 73 39 22 1937 1494 62 568 493 192 98 6596 16 543 42 4 2 37 483 11 428 18 53 8 852 789 311 2734 5112 234 33 5391 12 63 1988 591 359 52 46 129 611 7 37 413 87 988 73 976 5 36 53 84 9382 572 7153 32 91 32 86 945 96 123 5 44 25 162 4 99 39 881 85 5 7777 555 862 63 549 11 996 48 9274 71 29 27 5495 236 223 741 27 14 4 1763 62 63 85 93 372 93 8 11 52 462 4 4 34 119 383 16 215 3 682 364 77 41 46 4 97 16 74 27 81 39 61 3 49 35 1759 6318 84 41 918 62 281 66 449 36 889 7
18 21 21 58 46 921 77 499 928 12 621 23 7138 741 361 15 44 476 7 265 15 5 654 14 26 649 284 136 97 48 329 742 5 6 9 869 3 98 6977 48 35 96 8962 462 1 5265 99 85 19 694 416 9 1 392 923 326 4 1 29 73 7379 8 7 23 437 584 616 428 695 29 43 15 7 71 119 526 398 96 49 2656 196 426 827 42 619 2 69 27 441 74 9 55 979 31 18 73 74 43 463 5711 3 21 698 67 53 946 964 78 213 8 136 6 16 45 48 984 47 77 759 554 38 258 45 64 96 3686 648 1 85 626 342 14 3497 5 3774 339 9 436 3 53 61 96 84 569 9 1612 683 95 129 49 77 2 2659 46 86 9 4 9112 62 9 5 9 224 77 189 97 8 21 7 9836 34 9339 778 93 5 94 32 688 65 997 8 58 2625 896 66 27 26 28 3 3 84 23 568 4955 51 5 999 696 717 911 72 41 82 35 5 858 699 4 1 24 8 6 8193 22 48 19 58 94 65 4 36 3781 14 26 789 5 12 212 1 39 76 6 1 5 5218 56 583 6 46 31 4 3294 624 23 178 61 88 22 76 2 37 81 34 1 492 78 6 56 53 43 628 318 216 3 129 294 71 93 377 6 364 37 25 275 783 2 92 45 36 5 35 959 76 1 57 39 454 3 11 9 128 7 2 2949 7 252 34 36 7 532 32 69 33 3351 4659 83 3 1266 83 35 4 9 371 53 866 63 6265 11 1 877 17 319 2 7 6455 63 9 675 5 57 78 65 565 457 59 3 9969 27 7836 1 39 2 44 54 162 7 34 275 328 334 26 9876 4 671 526 79 82 1 14 78 3 2822 53 7474 715 85 42 68 25 5 88 5358 1 393 9 69 47 7792 722 953 65 3 6 67 14 4787 491 64 5963 13 824 53 755 4 52 1835 22 7 73 37 9475 9 5 45 5637 69 14 247 2 16 58 9 77 8271 17 212 452 3 91 4227 5932 72 6 7251 35 7 67 94 444 318 5 19 71 914 2883 513 81 2 511 38 85 15 7 32 8 79 219 14 5682 4239 892 13 1 54 89 42 5 18 852 573 85 35 5 76 412 6 431 9 37 1319 261 7 6 27 63 181 13 573 738 272 58 3 37 45 623 951 37 745 74 948 84 627 13 28 598 9139 262 2817 7 448 63 71 427 5 7359 9 9 9 15 133 7653 73 988 879 517 89 77 4491 588 34 762 54 463 547 33 53 54 98 324 85 679 59 3 87 81 1258 2 6111 36 579 531 16 2 6376 1268 8861 636 593 621 81 8175 5 255 8 48 318 41 74 81 6 6 884 74 24 2584 92 97 27 36 31 56 96 94 547 49 369 76 8673 28 87 19 5854 126 61 41 538 56 82 37 574 55 3951 195 745 5 71 21 722 5 1 182 935 4 1226 281 4 95 74 2597 556 3355 7762 517 75 47 84 8 645 221 5 14 2 4 75 4541 827 2 53 7 1 717 699 6 739 6 95 14 951 638 984 2 58 252 1 87 962 14 849 6 321 64 317 9871 591 1 9414 3 415 72 9 63 82 53 3 988 3 2 63 16 12 78 59 33 75 53 73 61 9 95 7 7131 894 89 653 4 48 8 74 63 1 793 6952 19 2 653 966 36 4 13 6 8 695 22 5 33 79 55 557 914 92 82 547 478 23 792 1 6 17 25 1 6 26 2 31 29 1 2895 4838 1 817 98 626 94 67 5722 3 583 413 383 883 132 162 6811 746 3 8 533 197 731 24 9 236 47 8 1 47 922 6 7 3 3 65 76 565 3 97 81 14 5263 19 1 665 891 59 5139 6 5 344 4 23 8 355 34 67 73 256 89 68 77 39 672 593 424 415 54 3 886 57 4743 13 4 71 353 31 28 4 57 9 85 81 6 799 41 281 889 657 94 896 2 736 45 96 53 83 77 59 333 67 5 919 424 613 36 134 562 4 139 96 179 5 756 45 8 76 7 5981 9 74 867 71 3 82 2 725 38 83 19 22 2 29 9 37 14 96 5 77 6367 7825 6 47 1423 171 7 12 744 582 19 6 5 44 55 46 236 72 88 5 78 537 27 4432 36 757 89 835 59 9 667 6638 159 57 91 696 739 3 13 54 75 581 21 71 5 91 7 652 4794 386 8243 75 19 68 13 121 6 169 4 64 3 412 4 14 83 55 1 5 7274 169 161 53 484 4 234 96 7423 94 48 14 6683 769 812 981 64 53 6 9837 23 48 88 22 37 48 5 54 27 472 8 9 14 526 877 88 282 4 42 491 69 52 25 7 63 24 41 74 36 37 5 4 99 7 4419 5711 33 7 723 25 112 74 219 73 146 424
* * * + * * * * + + + + + * + * + + * * * * + * + + + + * * + + + * + + + + + * * + + * + + * * + * + + + * * * + * * * + * * * + * + + * * + + * + + + * + + + * * * * * + * + * + + * * * * + * * + + + * * + * * * * + + * * * * + * + + + * + * + * * + * * * + + + + + + * * * * * * + * * * + + * + + + + + * + * + + * + + * + * + * + * + + * + + * + * * * + + * * + + * + * * * * + + + + + + * * * * + + + * * + * * * + + * + * * * * * + + + + * + * * * + + * * * * * + * + * * * + + * + + + + * + * + + + * * * * * + + * * * + + + + + + * + + * * + * * * * + + + * + + * + * * * * * + + + * + * + * + * * + + * * + * * + + * * * * + + * * + * + + + + * * * + * * + + + * + * + * * + * * * + * * + * + + * * * + + * * * * + + + + * + * * + + + * * * * * + * * * * * * + + * + + + * * * + + + + * + + + * + * + * + + * * * * + + + + + * * + + * + + * * * + * + * * + + + * * + * + + + + * + + + * + + + * * * * * * * + + * + * + * + + + * + + * + * * + * * * * + * * + * * + * + + + * * + + + * + + * * * + * + * + * + + + * * * * + + + + * + * * + * + * + * * + * * * * + * + * + * + * + + + * * + * + + + + * * * + * * + * * * + * + + + * * + * * * + + + + + + + + * + + * * + + + + * * * + * * * * + + * + * + * * + * + + + + + + * * + + + + * + + + + + + + * * + + * + * * * * * * * + + * * * + * + * + * * + * * * + + + + + + + + * + + + + * * + + + * + * + + + + * + * * * + * + * + * + * + + + * * * + + + + + * * * * + * + + + + * + * * + + + + + + + + * + + * + + * + + + * * + + * + + + * + * + * + + + * * * + * * * * * + * * + * * + * + + + + + * * + + * + * * * * + + + + * * * * * * + * * + + * + * + * * * + + * + * + + + * * * * * * * + + + + * * * * * * * * * * + + * + + + + + * * * * + + + * * * * * + * * * * + + + + * + + * * + + * * * * * + * * * * * + + * + + * * + * + + + * * + * + * * + * + + + * + + + + * + + * * * + * + * * * * * + + + * * + + * + + * * * + * + * + + * * * + + + * * + * * + * * * * * * * * + + * + * + + * + * + * * + * + * * + * + + + + + * * * * * * *

23
day6/part1.py Normal file
View File

@@ -0,0 +1,23 @@
from math import prod
from pathlib import Path
FILE = "input.txt"
def main():
raw_lines = Path(FILE).read_text().splitlines()
lines: list[list[str]] = [line.split() for line in raw_lines if line.strip()]
problems: list[list[str]] = [list(col) for col in zip(*lines)]
return sum(compute([int(x) for x in problem[:-1]], problem[-1]) for problem in problems)
def compute(vals: list[int], op: str) -> int:
if op == '+':
return sum(vals)
elif op == '*':
return prod(vals)
else:
print(f"unknown operator: {op}")
return 0
if __name__ == "__main__":
print(main())

32
day6/part2.py Normal file
View File

@@ -0,0 +1,32 @@
from itertools import groupby
from math import prod
from pathlib import Path
FILE = "input.txt"
def main(file: str = FILE) -> int:
*value_rows, operator_row = Path(file).read_text().splitlines()
operators = operator_row.split()
# Columns represent vertical numbers; blank columns separate problems.
columns = ("".join(col).strip() for col in zip(*value_rows))
operands = (
[int(n) for n in group]
for is_value, group in groupby(columns, key=bool)
if is_value
)
return sum(compute(vals, op) for vals, op in zip(operands, operators))
def compute(vals: list[int], op: str) -> int:
ops = {"+": sum, "*": prod}
try:
return ops[op](vals)
except KeyError:
raise ValueError(f"unknown operator: {op}")
if __name__ == "__main__":
print(main())

4
day6/test.txt Normal file
View File

@@ -0,0 +1,4 @@
123 328 51 64
45 64 387 23
6 98 215 314
* + * +

142
day7/input.txt Normal file
View File

@@ -0,0 +1,142 @@
......................................................................S......................................................................
.............................................................................................................................................
......................................................................^......................................................................
.............................................................................................................................................
.....................................................................^.^.....................................................................
.............................................................................................................................................
....................................................................^.^.^....................................................................
.............................................................................................................................................
...................................................................^.^.^.^...................................................................
.............................................................................................................................................
..................................................................^.^.^.^.^..................................................................
.............................................................................................................................................
.................................................................^.^...^...^.................................................................
.............................................................................................................................................
................................................................^.^.^.^.^.^.^................................................................
.............................................................................................................................................
...............................................................^.......^...^.^...............................................................
.............................................................................................................................................
..............................................................^.^...^.^.....^.^..............................................................
.............................................................................................................................................
.............................................................^...^.^...^.....^.^.............................................................
.............................................................................................................................................
............................................................^.^.^.^...^...^.^.^.^............................................................
.............................................................................................................................................
...........................................................^.^.^...^.^.^.^.^.....^...........................................................
.............................................................................................................................................
..........................................................^.^.^...^.^.^.......^.^.^..........................................................
.............................................................................................................................................
.........................................................^.....^.....^.^.....^.^.^.^.........................................................
.............................................................................................................................................
........................................................^.....^...^.^.^.....^.^.^.^.^........................................................
.............................................................................................................................................
.......................................................^.^.^...^.^.^...^.^.^.^.^.^.^.^.......................................................
.............................................................................................................................................
......................................................^.^.^.^.^...^.^.^...^.....^...^.^......................................................
.............................................................................................................................................
.....................................................^...^.^.^.......^.....^.^.^.^.^...^.....................................................
.............................................................................................................................................
....................................................^.^.^...^.....^.^.^.^.^.........^.^.^....................................................
.............................................................................................................................................
...................................................^.^.^.^.^.^...^.^.....^...^.^...^.^.^.^...................................................
.............................................................................................................................................
..................................................^...^.^.^.^.....^.^...^.^.^.....^.^.^.^.^..................................................
.............................................................................................................................................
.................................................^...^.^.^.^.^.^.^.......^.^.^...^.....^.^.^.................................................
.............................................................................................................................................
................................................^.....^.^.^.^.^...^...^.^.^.^...^.^.....^...^................................................
.............................................................................................................................................
...............................................^...^.^.^.^.^.^.^.^.^.^.^.^.^.^.....^.^.....^.^...............................................
.............................................................................................................................................
..............................................^.^.^...^.^.^.^...^...^...^.^.....^.^.^.^.^...^.^..............................................
.............................................................................................................................................
.............................................^.^.......^.^...^...^.^.^.....^.^...^...^.^.^...^.^.............................................
.............................................................................................................................................
............................................^...^.^.^.^.^.^.^.^.^...^...^.....^...^.^.^.^...^.^.^............................................
.............................................................................................................................................
...........................................^.^.^.^...^.......^.^.^.^.^.^.^.^.^.^.^...^.......^.^.^...........................................
.............................................................................................................................................
..........................................^.^.^...^.^...^.^...^.^.^.^.......^.^.^.^.....^...^.^...^..........................................
.............................................................................................................................................
.........................................^...^.^.^.^.^.^.^.^.^.^.^...^.^...^.^.^.^.^.^.^.^.^.^.....^.........................................
.............................................................................................................................................
........................................^.^.^...^.^.^.....^.^.^...^.^...^.^.^.^...^.^.^.^.^.^.^...^.^........................................
.............................................................................................................................................
.......................................^...^.....^.^.^.^.^.^.^...^.....^.^...^...^.^...^.^.^.^.^.^.^.^.......................................
.............................................................................................................................................
......................................^...^...^.^.....^...^.^.^...^.^.^.^.^...^.^...^.^.^.^.^.^...^...^......................................
.............................................................................................................................................
.....................................^...^.^.^.^.^.^.^.^.^...^.^...^.....^.^.^.^.^...^.^...^...^...^.^.^.....................................
.............................................................................................................................................
....................................^.^.^.....^.^.^.^.^.^.......^.^.....^.^...^.^.^.^.^.^.^...^...^.^.^.^....................................
.............................................................................................................................................
...................................^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.....^...^.^.^.^...................................
.............................................................................................................................................
..................................^.^.^...^...^.^...^.^.^.^.^.^.^...^...^...^.^.^.^.^.^...^.^.....^.^.^.^.^..................................
.............................................................................................................................................
.................................^.^...^.^...^.^.^...^.^.^.^.^.^.^...^.^.^.^...^.....^.^...^...^.^.^.^.^.^.^.................................
.............................................................................................................................................
................................^.^.......^.^.^.^.....^.^.....^...^.^.^.^.^.^.^.....^.^.^.^.^...^...^.^.^...^................................
.............................................................................................................................................
...............................^.^.^...^.^.^.....^.^.^.^.^.......^.^...^.^.^.^.^.....^.^.^...^.^.^.^...^.....^...............................
.............................................................................................................................................
..............................^...^...^.^.^...^...^.^.^.^.^.^.....^.^.^.^.^...^.....^.^.^.^...^.^...^.^.^.^...^..............................
.............................................................................................................................................
.............................^.^.............^.^.^...^.^.^.^...^.^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.....^.^.^.^.^.^.............................
.............................................................................................................................................
............................^.^.^.^...^.^.^.^.^.......^...^.^.^.^.....^.....^.......^.^.^.^.^.^.^.^.^...^...^.^.^............................
.............................................................................................................................................
...........................^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.......^.....^.^.^.^.^.^.^.^.^...^...^.^.^.^.^.........^...........................
.............................................................................................................................................
..........................^...^.^.^.^.^.....^.^.^.^...^...^.^.^.^.^.^.^.^...^.^.^...^.^.^...^.^.^...^.......^.^.^.^..........................
.............................................................................................................................................
.........................^.....^.^.^.....^...^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.......^.^.^.^.^...^.....^.........................
.............................................................................................................................................
........................^.^.....^.^.^.^.^.^.^...^...^.^.^.^.^...^...^.^.^...^.^.^.^.^...^.^.^...^.^.^.^.^.^.^.^...^.^........................
.............................................................................................................................................
.......................^.^.^.^...^...^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.^.^...^.^...^.^.^.^.^.^.^.....^.^...^.....^...^.^.......................
.............................................................................................................................................
......................^.^.^.^.^...^.^.........^.^...^.^.^.....^.^.^.^.^.^.^...^...^.^...^.^.^...^.^...^...^.^.^...^.^.^......................
.............................................................................................................................................
.....................^.^.^.^.....^.^.^.^.^.^...^.^.^.^.^...^.^.^.^.^.^.....^.^...^.^.^.^.^...^.....^.^.^.^.^.^.^.^.^.^.^.....................
.............................................................................................................................................
....................^.............^.^.^.^.^.....^.^...^.^.^.^.^...^.^.^.^.^.^.^.^.....^.^.^.^.^.^.....^...^...^.^.^.^...^....................
.............................................................................................................................................
...................^.^.....^.^...^.^.^.^.^.^.^...^...^...^.^.^...^.^.^.^.^.^.^.^...^.^.^.....^.^...^.^.....^...^...^.^.^.^...................
.............................................................................................................................................
..................^...^.^.^.^.^.^.^.^.^.^...^.^.^.^...^.^.^.^.^...^.^.^...^.^.^.....^.^.....^.^.^.^.^...^.......^.^.^...^.^..................
.............................................................................................................................................
.................^.^.^...^...^...^.^...^.^.....^...^.^.^.^.^.....^.^.^.^.^.^...^.....^.....^.....^.^.^...^.^...^.^.^.^.^.^.^.................
.............................................................................................................................................
................^.^.^.^...^.^.^.^.^.^...^.^.^...^.^.^.......^.^.^...^...^.^.^...^.^.^.^.^.^...^.^.^.....^.^.^.^.....^.^.^...^................
.............................................................................................................................................
...............^.^.^.^...^.^.^.^.^...^...^.^.....^.^.^.^...^.....^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.^.....^...^.....^...^.^...............
.............................................................................................................................................
..............^...^.^...^.^.^...^.^.^.^.^.^.^.^.^.^.^...^.....^.^.^.....^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.....^..............
.............................................................................................................................................
.............^.^.^.^.^.^.^.^...^.^.....^.^.^.^...^.^.^.^.^.^...^...^.^.^.^.^.^.^.^...^.^.^.^.^...^...^.....^.^.....^.^.^.^.^.^.^.............
.............................................................................................................................................
............^...^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.....^.^.^.^.^.^.^...^.^.^...^.^.^.^.^.....^.^.^.^.^.^.^.^.^...^...^.^.^............
.............................................................................................................................................
...........^.^.^...^.^.....^.^.^...^.^.^.....^.^.^.^.^...^.^.^.^.^...^.^.^.^...^.^.^.........^.^.^...^.^...^.^.^.^...^.^.^.^.^...^...........
.............................................................................................................................................
..........^.^.^.^.^.^.^.^.^.....^.^.^.^.^.^.^.^.^...^.^.^.^...^.^...^...^.^.^...^.....^.^.^.^...^.^.^.^.^.^...^.^.^.^.^...^.^.....^..........
.............................................................................................................................................
.........^.........^.^.^.^.^.^.^.....^...^.^.^.^...^.^.^.....^.^...^.^.^...^.^...^.^.^.....^.^.^...^.^.....^.^.^.^.......^.^.^.^...^.........
.............................................................................................................................................
........^.^.^.^.^.^.^.^.^...^...^...^.^...^.^.^.^.^...^.^...^.....^.^...^...^...^.^...^.^.^...^.^.^.^.^.^...^.^.^.^...^.^.^...^.^.^.^........
.............................................................................................................................................
.......^...^...^.^.^.^.....^.^.^.^.^.^.^.^...^.........^...^.^...^...^...^.....^.....^.....^.....^...^.^.^...^.^.^.^.^...^.^.^.^.^...^.......
.............................................................................................................................................
......^...^.^.^...^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^...^.^.^.^...^.^...^.^.^.^.^.^.^.^...^...^.^.^.^.^.^.....^.^.^.^.^.^.....^.^.....^.^......
.............................................................................................................................................
.....^.....^.^.^.^.^...^.^.^...^.^.......^...^...^.^.^.^.^.^.^.^.^.^.^.^.^.....^.^.^...^.^.^.^...^.^.^.^...^.....^.^.^.^.^.^.^.^.^.^.^.^.....
.............................................................................................................................................
....^.^.^.^.....^.^.^.....^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^...^.^.^.^.^.^...^...^.^...^.^.^.^.^.^....
.............................................................................................................................................
...^.^.^...^.^.^.^.^.^.^.......^.^.....^.^...^...^.....^.^.^.......^.^.^...^.^.^.^.^.^...^.^.^...^.......^.^...^...^.^.^.^.^...^.^.^.^.^.^...
.............................................................................................................................................
..^.^.^...^.^.^.^.^...^...^.^.^...^...^...^.^...^...^.^.^...^...^...^.^.^...^.^.^.^...^.^...^...^.^...^.........^.^.^.^...^.^...^.^.^...^.^..
.............................................................................................................................................
.^.....^.^...^.^.^.....^...^...^...^.^...^.^...^...^.^...^.^.^.....^.^.^.^...^.^.....^.^...^.^.^...^.^.....^...^.^.^...^.......^.....^.^.^.^.
.............................................................................................................................................

21
day7/part1.py Normal file
View File

@@ -0,0 +1,21 @@
from pathlib import Path
FILE = "input.txt"
def main():
raw_lines = Path(FILE).read_text().splitlines()
beams = {raw_lines[0].index('S')}
splits = 0
for line in raw_lines[1:]:
for i, c in enumerate(line):
if c == '^':
if i in beams:
splits += 1
beams.remove(i)
beams.add(i-1)
beams.add(i+1)
return splits
if __name__ == "__main__":
print(main())

32
day7/part2.py Normal file
View File

@@ -0,0 +1,32 @@
from pathlib import Path
from functools import cache
FILE = "input.txt"
class Foo:
def __init__(self, grid: list[str]) -> None:
self.grid: list[str] = grid
def timelines(self) -> int:
start = self.grid[0].index('S')
return self.traverse(start, 1)
@cache
def traverse(self, position: int, level: int) -> int:
grid = self.grid[level:]
if not len(grid):
return 1
if grid[0][position] == '^':
return (
self.traverse(position-1, level + 1) +
self.traverse(position+1, level + 1)
)
return self.traverse(position, level + 1)
def main():
raw_lines = Path(FILE).read_text().splitlines()
return Foo(raw_lines).timelines()
if __name__ == "__main__":
print(main())

16
day7/test.txt Normal file
View File

@@ -0,0 +1,16 @@
.......S.......
...............
.......^.......
...............
......^.^......
...............
.....^.^.^.....
...............
....^.^...^....
...............
...^.^...^.^...
...............
..^...^.....^..
...............
.^.^.^.^.^...^.
...............

1000
day8/input.txt Normal file

File diff suppressed because it is too large Load Diff

45
day8/part1.py Normal file
View File

@@ -0,0 +1,45 @@
from math import prod, sqrt
from pathlib import Path
from typing import TypeAlias
Point: TypeAlias = tuple[int, int, int]
Circuit: TypeAlias = set[Point]
FILE = "input.txt"
def main():
lines = Path(FILE).read_text().splitlines()
points: list[Point] = [parse_point(line) for line in lines]
distances = sorted([
(distance(p1, p2), Circuit([p1, p2]))
for i, p1 in enumerate(points)
for p2 in points[i+1:]
], key=lambda x: x[0])
all: list[Circuit] = []
for (_, circuit) in distances[:1000]:
connected = [
a
for a in all
if circuit & a
]
all = [a for a in all if a not in connected]
all.append(Circuit.union(circuit, *connected))
all = sorted(
all, key=lambda x: len(x), reverse=True
)
return prod(len(c) for c in all[:3])
def distance(p1: tuple[int, int, int], p2: tuple[int, int, int]):
x1, y1, z1 = p1
x2, y2, z2 = p2
return sqrt((x2-x1)**2+(y2-y1)**2+(z2-z1)**2)
def parse_point(line: str) -> Point:
x, y, z = line.split(",")
return (int(x), int(y), int(z))
if __name__ == "__main__":
print(main())

53
day8/part2.py Normal file
View File

@@ -0,0 +1,53 @@
from math import prod, sqrt
from pathlib import Path
from typing import TypeAlias
Point: TypeAlias = tuple[int, int, int]
Circuit: TypeAlias = set[Point]
FILE = "input.txt"
def main():
lines = Path(FILE).read_text().splitlines()
points: list[Point] = [parse_point(line) for line in lines]
distances = sorted([
(distance(p1, p2), Circuit([p1, p2]))
for i, p1 in enumerate(points)
for p2 in points[i+1:]
], key=lambda x: x[0])
return prod(
p[0]
for p in last_circuit(
[c for _, c in distances], len(points)
)
)
def last_circuit(circuits: list[Circuit], total: int) -> Circuit:
all: list[Circuit] = []
for circuit in circuits:
connected = [
a
for a in all
if circuit & a
]
all = [a for a in all if a not in connected]
all.append(Circuit.union(circuit, *connected))
if len(all) == 1 and len(all[0]) == total:
return circuit
assert False, "unreachable"
def distance(p1: tuple[int, int, int], p2: tuple[int, int, int]):
x1, y1, z1 = p1
x2, y2, z2 = p2
return sqrt((x2-x1)**2+(y2-y1)**2+(z2-z1)**2)
def parse_point(line: str) -> Point:
x, y, z = line.split(",")
return (int(x), int(y), int(z))
if __name__ == "__main__":
print(main())

20
day8/test.txt Normal file
View File

@@ -0,0 +1,20 @@
162,817,812
57,618,57
906,360,560
592,479,940
352,342,300
466,668,158
542,29,236
431,825,988
739,650,466
52,470,668
216,146,977
819,987,18
117,168,530
805,96,715
346,949,466
970,615,88
941,993,340
862,61,35
984,92,344
425,690,689