2025(03): jolly joltage

This commit is contained in:
2025-12-03 08:18:38 +01:00
parent 14f6ed8f8c
commit a28fe8271c
5 changed files with 270 additions and 3 deletions

View File

@ -34,3 +34,30 @@ You'll need to find the largest possible joltage each bank can produce. In the a
The total output joltage is the sum of the maximum joltage from each bank, so in this example, the total output joltage is `98` + `89` + `78` + `92` = _`357`_. The total output joltage is the sum of the maximum joltage from each bank, so in this example, the total output joltage is `98` + `89` + `78` + `92` = _`357`_.
There are many batteries in front of you. Find the maximum joltage possible from each bank; _what is the total output joltage?_ There are many batteries in front of you. Find the maximum joltage possible from each bank; _what is the total output joltage?_
### Part Two
The escalator doesn't move. The Elf explains that it probably needs more joltage to overcome the [static friction](https://en.wikipedia.org/wiki/Static_friction) of the system and hits the big red "joltage limit safety override" button. You lose count of the number of times she needs to confirm "yes, I'm sure" and decorate the lobby a bit while you wait.
Now, you need to make the largest joltage by turning on _exactly twelve_ batteries within each bank.
The joltage output for the bank is still the number formed by the digits of the batteries you've turned on; the only difference is that now there will be _`12`_ digits in each bank's joltage output instead of two.
Consider again the example from before:
987654321111111
811111111111119
234234234234278
818181911112111
Now, the joltages are much larger:
* In `987654321111111`, the largest joltage can be found by turning on everything except some `1`s at the end to produce _`987654321111`_.
* In the digit sequence `811111111111119`, the largest joltage can be found by turning on everything except some `1`s, producing _`811111111119`_.
* In `234234234234278`, the largest joltage can be found by turning on everything except a `2` battery, a `3` battery, and another `2` battery near the start to produce _`434234234278`_.
* In `818181911112111`, the joltage _`888911112111`_ is produced by turning on everything except some `1`s near the front.
The total output joltage is now much larger: `987654321111` + `811111111119` + `434234234278` + `888911112111` = _`3121910778619`_.
_What is the new total output joltage?_

View File

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
HostUrl=about:internet

200
2025/03/input Normal file
View File

@ -0,0 +1,200 @@
2215452689925244273244333436189317446384838478525478824435233342352236255624326767355438753493222423
1222232323222232132222323221226222225212221213232122232311152232223212123622111212223162322221323211
3786645737446363554463656544667372864465545434545435744345766553343446943531537627746253556233634463
8453332352565142143524531446335443437325325152243234623554533532314513854524534532534224242344434525
3533243449264427643542468452244718248315345733634133352136441275626213553347866334222454323754335453
5535625542655597356352273256244443153325356634941773484673334456353334423458343574664633345343665513
2252332222532292346231412134324235332443333323223313377333323737314334332224532223813332224315253334
6122221212223222221222221122232243223216125222134222113211222222222223423221222333331212121221212222
3373117222222512252222213221487225222222122214221232724313232124722214335222282233236222232242227374
4324221311332133124311141233224134334423134124444233221233312314231241241143121423121121431142256789
2722832232823132312232242222312311332223312432122131823122312222222421622221323221321222222523323232
2231133421122122223222222212222113131222325222122222322212212122222222212321322241522242222221115122
4423313224213441432454432222125442433411323443323133284443431324633442334622623233642434248325321423
4125312414443568333545464313544326176742543256235346446552356366542153744336443643522322645254554644
3644334363342344567643443444444337444344445243654544444365418444443444554523654452443346544244264644
5323444342233135324221242454223642343236246226342152225323242212434243232333142123914226712323424443
6639379995398867788897889288988749385667849837673775358695799893677978593975529534843835737869638469
3236752433626656333544544555126734453323343658344256258555334455342244266243325556734323635333214248
4351655754585521442543947656672256644546555474465433554962535585454738657555244553444643564455354452
2237222225142212451322332222313221222212225221222422211222222722322222242271214331231225222222223223
2834226834525774934433434225284665362232524692858947373345337344135638933531467333732323441653933392
5547365555688654773656643376555665966753267761765346664654556756454675653644573276576656677465466463
6273322623671457517623463322243246837463253252345372646454348235631422283632253433222263367533365247
3225533544429667786914823542454241235224694587356724335421246656612452243836523367132455748296656375
1235212235252334235645542554324336453259222442425243442423325426222264223454235232434222732322373554
5644452554444442344444424444353274364744434532545757444734343347544473446442334433445375345447545435
8999658566789898968985984977945797957698566998575976788977555898595999678878896598558588879888579896
7673764525764117141444537734457367533754724553517727761354114366572756664372565575113736665611522589
4567555557558775667746566745765545556579756615865564655547695665475466764657455294936646645557796555
6242222235121555242223852114242372143458434412422523112222413312522242525223224321221252224267142275
3526223262424234223142334154422313233224241422322432324457133214264521253314474222232111422152244314
4534312358531653444435326421254565555465423365354453543523536263445565534455584255374543435362545335
3825535635733372332522823873676373423922224632436776253233323454953456442636732266264262616444336336
5353444554254525334214351333215441351234241244213121132131111335525432432545215325155351333115536789
2232233243212223242122232423422113222124312331312332433443224222221233226431312241222333334222322433
3454645562342347355436354644554324536534654344455463434663434643375144443244653554534444443632264525
6444254352145644483452712344344242473255424853441343154352436244265832452435433523335733574435377432
3132312235541541525421141124122133422222211321132415273342244222223322121332222335232251222321222322
3545235354434834445435443449444556554448644644554455445555434484434454443565463444444443344545553514
4443544544454556544334342545455335444475164454554444635454434587684554654654254453344537345246543335
3222223236464122221664352262593664263356232425432152232551566222241725266234335212235116173422332146
8154775772554636646858766338544657562185866455861787725652348486767447777458666348356666564766855855
1221222222412312213329222232231222313222225832222223212633222212242332222322221222523223223627226212
2222621222122231222212221222216212222224122122221273422521121222254255163213221224222222542212223224
3444434584135753465934134454468646644634442644124343244465631544464373363183345356351464634526446655
7535235444435124425134323341522455654447423246149234342454321243444424254475444424444256284255864264
3131313322533347523573323445533331735635343235135323336143723343224445344333323633634335333535356133
9864544535884858839444264443453868683432464413666367475676283377453374427472664226448645524563658746
2344334543444343473433354533445255342453454544434543344423445494434334334244342443332233444324233334
2232152322245422563233222133262421322232147523582212222382243667315326412132225136312244182233222421
2123254241324122223222522322321153315223225232224224252414315222161333615743522345322124233123334232
6543555544545243244215456352254534155423335323523329232432543533435135436283144925561434335423442855
3233234434333374432343229743323334333293333233334233323332332133433333333323542323323435333333322333
3465684536348436622676875743446453754523585874478737727444474335854637375237654363638248348394844556
4454634436745226466443443547374435255464644435453736564742648446533347364374743474472452345424444343
8933656355766372657646393747397553984476238556774637844786685554555467468673679656657625666666977846
2333632233554124665936524253474446425624625433364725536353342552734233262355365435653413364336524653
2222222312212122322222221211522312131222322122623211332278223322212325522342315233222332213721141221
1181298225622722112252222117234262422232221211122423762242722826874212221221225132312512231221413822
2321232222323212223322646123213212333223252324632333332222222232331135232232352237222222132214344322
1221322122552522127332262412222222222223722163125212282122622236813222272276282727221132227122221228
5223431413442256232434332146142223345321523733223235542523322245322422331522221362325123221313244232
3432342453333434433312322343332342314333342232534333333144143133333324323343413333344332433322213363
3443454243553355422634953443424654364624344243453332534233333343238365443645241372433324332332533332
4321143226313233531332344322244253232242332243223123124132333223242223424234224342442423323123222234
2565554455555455565555575555545555555555343655656664655955555524575455445455536455556454555555555535
2611557322542172125114222232122124162122122742262382212232121221322342722222222332332225122315333125
2332323522212212332222433231213343123312333222162121331332423122233282313321222332293222232313842232
2835534262526454435243425433472642444444655255455355574643325724455636454555425524564765462542276435
4635364554333454582794449233243545437574434533335433853233342238272466345445537345237554444247354333
4333426431534431243344454563772374252343585223522353233433348353263842323433453427247322233435454137
1222132232212222323332222313222422222231521322232821214212222323222226232323222221321232122222222233
2623232214342242425243213161244233232426313133233434233223621343334414224462316424454253131342226422
9666376743999796547977575657648753956766679456576796755475577565597557567666747856576737577687465656
3221323512251221222233113321272241223213122233321222533324123232222231242422221322233263232222241135
4329444344437333432323234383342233343545443434334337552336563133435332233343155355345454345534333328
4322122245342322235322932142422222222222135272342623144221222263422224343242438122446253145333222311
5111411242372512222222421222235421521222124227523422232323222224542432262322255224232224222421624222
3434645343645334437732534134763436836633433344624613342315725323543833324453447244634344443243262433
2352125121414325322313332133522112225243242453311534432225422332334432322335224313323123262131431268
1325411226243322486221532343122531543532255252442433524212542244261525422422125513522424524225352414
2212322233332213512212133221122222213222223122122222131332222338224223422222311234422132323322232231
4897333563333234432633355484153546233136553473624355563355943643465324342137488327436345332534932423
1221459444444636582465956235642243223384551562622244642455225447416224482347546234532454253662125524
2224252242913642222223234142242262234245262542645321344129112242132433232615524865623262243237414254
4333433343124243433223433254254363823363343133384344232243233743443345244616243424345332423422453134
5223272522231322222235222323722682522626222432751224522532272212433232812215388532222682524324672322
4322313351223222312434332421313331422431223322212222211512232121521472723232323353222222233243253223
3533452432222333331253213313221233233313531221331223332334432233313333323332523241433332532333322333
2667548542533647947376447456534253332366634443577595436763376955332447656464543374437474342363234783
5783362525339762394563884413365533775953756762777362336456335867357397225325253535736523557853521479
4342342532442342313324343343533324533234334243433243343333324232443433313343442324223324333332333343
4545553665353657625654244435735362656445955544446854442544374343695462575455553546456456264453355336
2236823222375633551232263326445312642331321533836332732422263284531332232263523728222243233337251235
4434225232343323322345443342342324235233532234323344323341333423344338344235443333134244234432133353
3535427435662254455763534552565243466554535538587536855524353824445332321243363553424357485556425455
3243533142324243343342423326453232333314445233531243365258335434213733324435252523223332433323435441
2333332323213332533682232333223123222452423233343422243414451332243322132132432222323334252233523226
2352212622323422223646412352333663366434244523322214314225214252523333314444272532353325651432222212
4224412213254531322212684336452464532314422242622247232211232113324232353524242242244412422432224332
4141324254125123524223333233432513333252322142112332133315222123322323335321353332322335651354323233
2433333321223142132253233212223262322562132322224393233242283322353562332233122313228322153336122323
3363323345423248353333332442633333332232432363353741452334233342635342455343223344433333533334355333
2522332243423524523231473333542353333333313535543333425333232333333734234522337335353443353134244341
6754223927727182758649563236142259682732236226357353842724527382266434622326472642328822522483667772
4325343252433432534455233455353233733235455434334245253353535362353354343443333335523343543222433334
3247123342234213252231234322242223222213213842322322242321133543322321322333332241223211122512334233
4221242932312112274233441256823412229862272232222432325623349331486322534236311328228221222226934353
2712212212333273212432213222222222232131231221825222222332231222347241212223233331241122223223518232
3222243222122323122314221233331232232323232322222232221324222122223222122242221412212233232222223232
2237344714333334236643423332423443575533235233233824353343633334523444344844944333333333335343233443
2345335322223323232331133334612334422122522123222322223242222223432423323323322343323442131533363462
2212222222423232232212111112212125224222222222121321221122213322212322223122223312422122222214512122
4322212414121425315331434443432324322222142433233232122222323351222362471222333253112223422223144154
2222132232422222122222133223123222221222132222332216322322262321132226221322222312211422221322233322
6544496363544536655347566343366445555553635355454326644636557433423664464346568943664659453574526365
2225224522242227222222222226222228225261122121426222212222242423224224224212233153122223546222216222
1122512224334223352842323222247124123444121428231422237433131433561222572235251332133243635444654452
1223243424443545212242425752321235232222418121221324222122244535223632321142372523414222122113122221
5423521472243222233282612211443224357222742254442233522322422234644524324421626372112123214942221717
5243133224735522212322225222122421152383252222322434232518421421422224222633236423112322234225322228
5352412344533435553635153222742223426726351253437235513461245342765482532473282334337657223335254572
5443337345554244344483533346125543555335416345524846653564434632452432544342344545545322523444444467
3343333423333322233433434423133334373243523732314126323332224236224224772332236323223331233223333432
4443246455466628754322175624332255352644542355375633425435344633963424365476464254738652659375635433
2222321822222123212123223222223243322214223222232212312222222222211341222222323211223322262223323432
1242522225241242144243333222225322222232222224232223232223241323342322423311111242333231541323122312
2322213371242423221143321223422422423321124212223222141233212622221312222132232232212241233232134234
3133333422333333333233432643233341322343333512326322351224365762341423332413222326524625532253234433
3343433233433222414332332424324323444633444324243342443113234434233443535444243334433332342324423633
5554457453542935751785345354748453843767685229732251456553855682427655945553359156263956756654965957
3634422353633333364333838665245354343593124485344363693433363643327367844633344273137732444334236443
7883345464543164533522413783327362422575552222566662274325345463353126237775878643633522155357245353
5367524233323333273641376325222633833513235543354334596334135335333335714383633529832313916528618443
2222112121211224522222221211622222231225412223222222235222223512722211231623226212212226122222522112
2292221222222222222222222222422111622112142222122322211222222212122222222222812122212322222322122222
2343644354332242544335444243235435322344341544265423547643343442433433415542349346325554244333224752
1342626272364794241632462836364432252262522241286223332413622442466422517221226256243232457113523386
4254356575547763246443254654367844361545533435377655464857245525664645654786446455436745664443664465
8877897263668879437651755889888787888866998987874696636775868588184988732871686767768888286952377878
4443643928243353359443435344857573484452282345235292344275125734343286335554432421454244538326327345
3343293359544353533794535325554345853783435834333355425443554738335824983324733443423543652956494534
4487434445435354424344262454446344342443464334341124344442444224153422242144245442344444444264442424
4852231451722225222152422222211724232413221162422211412323528132322531322222212332453292523122212222
2533125343443433331332213222254415445232135222335632333316516422353424124362374535242333352221235243
1213333123221232133423322145214133222222322226332323342242122333223244323229332413371342222427355322
2223432242232226222222223233264333133233211221233332223322521222233221232529421223222234262323311331
4333251434214664354221552221322252343443351455445251662345456445645454345241255424544544246255343245
6543447336822333353734334549663334737733335633933436547274264143373534549252333364733134356363633755
2421225323335434443342622284243234333432438234242113332333334222332432822441442333334232341523422433
2244122542223238422128322324342256923444424224325263734432452623564127342242643432424572223244356732
2345224549237333932324222335334242245233324253921237223324152312333463342422624243433834322113233372
2236326322323139122242822223232334331123532421322242353233223334423333232235241533322211223213252232
1423322215223123233332222322222242332212321323232231122522224222423234323232333222122231212321414252
2677566548347767364386846141372765763337332238362566163713256568882156338434744825582542117315858459
3113342423363622231122322421242227224259232232222231522322134232333332272311333322222633232432323373
2222422122222133223623223323135632242432413432332222323223232335524333223321314332714222224351233211
4263327583154322543324523434624564135553564125446622222646545433322232532234433636652272242223234232
1521215625366133644532245623615562213146211216653153666111154441566211451633632546646313245546124789
2222222223232322142233222212122231332223111222283222211225422213222222232242222212252231223322322222
2212322222223222222221222115322214234222225222325222212232222322226133231241221322221122321332222221
4243224544324433253532226333833321424342236363152364364334423342433453433343334223232348216624824323
2242121352221222222222542222233352232322522312213223531342222126223412222532222412434224232213122433
3341233422233323323331232232232187329342385233323331273732243133313322322333232323223111213233343221
2112212322222322212222322322262222322128122225221222331322211721223213251125232222622222222212232222
4256325571555252345473125464248364234834464542332345543653455323215135885235753391455336255245254545
4424243555445453553441546755744454544545555133143553954425352853554545564474153646813552251665636444
4226234124378254424637323135223139574523552332353333253215325554423224635122321233234838122844256383
3343624433333336335634336323333433323332453433333313522334333363333321333243333333333333331333533632
5432332433322333261246223314112343332454215423442523214224422442333313624221242212514224334311322422
5145333254344357372346344527376323443453558562453346456633522274244363545356345536446524564233454284
4222323354147213322372128842432315225245323222124424132466332346342658442326244222123212423122463427
5123432273133331422233127732132227273224213165222721122333233343262283213232223434332322313343231233
7523972343477361377743956884687575443466739542777453463647373912825463342455373643625785555533268257
4213324141342324718322323224222134582626532922312232224711231355247332524212226422892822263225123623
1221222133133333213313233423221221222232233323343331234313233236333232332332332353322133234222323322
1324222332512532232325532322623344454413222242321444234232332242343422213323343222332344321442224231
1151223222162533222342825322433243224223622383232414322521524232268232723631322111224242221275225121
2233222423821611241444422334722333356141453136321242233311221221253242122342242723221122122574764322
8573255368427233541249342862965464536493678437533637576625889687456637652825457643483176999343198658
3244224244424643444229472636623243984414241464325683423334836437283334543623242248744844445444255424
4522895222223459222215242224321218938928231422228422322222522291345942435392232845332154532852338761
3252332432222223233223232312222232234263331424324244213733245323642222215123232632211152533443123423
4314642433623624333624333242262233433323334433222234331344432246333323226233324333254433432444424244
4434123323443252336355444433244434856354314442336544424248344344344464148454443245425424424444434543
3633644225434233462334334433334334244457453244225434744644357343345334344315442435435336265343352333
8511753365365353433545751734565554656442345565435633555555553454455244484375353835449714556575324136
1333534633222323212533322633234232122213532344333324532334611133332323322332621571214133333223333232
8747857539877346635974765766877575376767844547564476625546978745769777857787855766876866677674885783
5954947455377864765587667483737385776764967667567557377687557576775775576747374788787674527477967475
2323313232333223232722222211221222212343242221732312323232232332223452252123221332333341222342312331
5246523252273423333432545422334224443522222341333424273555446432242222344235842532143342442243235425
3332362543334362533336343234532534233532372333332337731132253512237233433432133328442433338322623323
2554445353152423523433348333335333634333243454324344334443543343233354334325553534533522353472684334
3252332422222212123233222122333352262253112222224222244222222313222223423912332212322232323713223152
2229222286292113252332322422222522521114553224422143124257322361232241222422232724144422212212742224
2223123222222213252126322422132131223213211223233316234222212222622222222323222231322211262112223224
2311233423122622631116321246121221261234224237222542222225222122217132274222324223432222224222522422
6634644474551646645574355664475663676736253675576458125356566663552375853445554345666675676853752767
5443322233234342223444233322543323223434393253133433243534223622425232323423422334442123542533333224

39
2025/03/part1.py Normal file
View File

@ -0,0 +1,39 @@
# Test testinput
with open("testinput", "r") as fp:
batteries = fp.readlines()
def bruteforce_joltage(battery):
"""
Makes all combinations and returns the largests
Complexity: O(len(battery))
"""
joltage_battery_max = 0
for i in range(len(battery) - 1):
for j in range(i + 1, len(battery)):
joltage = int(battery[i] + battery[j])
if joltage > joltage_battery_max:
joltage_battery_max = joltage
return joltage_battery_max
for idx_battery, joltage in enumerate([98, 89, 78, 92]):
assert bruteforce_joltage(batteries[idx_battery]) == joltage
output_joltage = 0
for battery in batteries:
joltage_battery_max = bruteforce_joltage(battery)
output_joltage += joltage_battery_max
assert output_joltage == 357
# Perform final stuff
with open("input", "r") as fp:
batteries = fp.readlines()
output_joltage = 0
for battery in batteries:
joltage_battery_max = bruteforce_joltage(battery)
output_joltage += joltage_battery_max
print(output_joltage)

4
2025/03/testinput Normal file
View File

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