Merge remote-tracking branch 'refs/remotes/origin/main'
This commit is contained in:
3
03/go.mod
Normal file
3
03/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module git.z1glr.de/advent-of-code-2025/03
|
||||
|
||||
go 1.25.4
|
||||
200
03/input
Normal file
200
03/input
Normal file
@@ -0,0 +1,200 @@
|
||||
1222222312332225132221222322223222212123112122221122321222132212122312222221212112222322211112122222
|
||||
1345446423422232333442846252125241622734244225359323445433441754253232142272634482426733122226243425
|
||||
4577785646656747466375765575483456466553659534557243455743516567366564563657487644966426447385374456
|
||||
8222241222244832332283327241231524722223244352322232213522125242245322283224432151246355541722522324
|
||||
5635743334524945473375734334333434335143733447653334825456648464763377423445683323144636458153553242
|
||||
3232232312232332323212122223223233223321211222211132312332324232222232322523312323232163333222323322
|
||||
2472322324223274543733231232327134352234642232134332324474422235367263242723634682312212321627217212
|
||||
2322173432233122122222222213121212122322122223443222342522222222251411222236234224413232123242322223
|
||||
3652868667537452366966235765333245635664416546663245643298725986543622252758383653626463865737627748
|
||||
3253353434242444324342234443345354345254334442434394133446153443846544445463344442443434235445352234
|
||||
5525553365254244555275437345525352655555522746447455432455324534325535325273245541464725355252535575
|
||||
2214425229352326112252442232322442223322421533421422132524224245252242545214333222331524435255222223
|
||||
2234124522332123154444451131323344345334231233643452432242214434344233242231242332234344421524422232
|
||||
3236463384444313444333424423252643421343424424235323434132354443426454435344525454443465344534334423
|
||||
4543423346942324444333211221223212242324282444324344223441284163344472232231533442334222493142444332
|
||||
2252414424434323225422335355623444534443242223425454222114434323343422333232215262245342315322124145
|
||||
2122646344333414322344334235233373362531215643422331422265651312416332422214424426224243324542223642
|
||||
3847153424154522215342336613544333655363532363224243424235531432231232223355334226233328533731422324
|
||||
4213313279221255132733337332676783336438397722223623627143243336265323866272222383326952231117437536
|
||||
3232133691332323342527227744573324433247223253622233171323332113722323235353712225334322234221572332
|
||||
3445335444436434327374244374433344434442444442144443444264833443473634342344644763335344533673334344
|
||||
6333292325523633354384344331338332264312366653353246484744834445326665525233525441397563944365838662
|
||||
1422232212232134233341212239222212422322511212211252221221221311232212122322342312122222212222232242
|
||||
4545663443455345754454364437755673136355444555752453744637424434742134442237535355363587654542364464
|
||||
3723323233422393333326837768263333265213832212132322233392861423235237313423222323336342333932322332
|
||||
2349332626622312523226252359247213331622422325232223293333234249496222352453182422439533232324235293
|
||||
3252554344223424221332333445133334222243533523322421453434312323722222434332343535223326331431344432
|
||||
3224323455245243765446462354444354565156446364328331212243352324112326343383442623343643333324452114
|
||||
2563171155451654324562512247376555764275624737724434776266221511514262446463627513517271167474535589
|
||||
2323221323223322223334221233241223231111213213212232232222332211322222532111222323231232322222332225
|
||||
7424783332616784611422874441346688443382343661511421287338824445411353727864326752163275477222364319
|
||||
3354533332333324343135355544433311324132422234444325333334323542434333323236543423444343227424343334
|
||||
3732574422333334533553366332367433652284326723242266162436673434447364637354732463774564353343333173
|
||||
4212223242312223221423321222214221222221122222221223322432331232222222224221234124112233123122123224
|
||||
3233434633732743545124537434234653353464343242543244546323364447233333572534344434245434343234545544
|
||||
2225242525223643221254336142222234373343222332224343332434265232343412424722166322326213372423448325
|
||||
2432322533332432732522234451432243624223143437138244633421392233224232322224425221313425321446222431
|
||||
2114424325322242324512124415314222144242143241432626422134224363342352224534344271233533532423443323
|
||||
3223224211211258211121421231242223222222212132732212251212221332224232244332223232225222224212212382
|
||||
1423131332321213313231313222233122533323233422232242231222232333331522222332121323333322232212122213
|
||||
5655554636456633545666665465556655366655654365545555366536746474736775544563574766645543646465536663
|
||||
3252755647445345577525346257335542222374212663671322343546264454567666534555544522382675823433726252
|
||||
3244651472243442224343562543518331333224445441454272421314953422141242425435544454532935313335535434
|
||||
2342333332321232221552333333344324343334632333232535253353445333332221242352242142233322232333422342
|
||||
2942122243614122123433252121292245182224241221326222442224135558253129224221315828732241442331372126
|
||||
2242122222421262311324444533242264443193322114222232212321121222333224312122336224333123333222223323
|
||||
2522362222253223782132236734313213411233672343453425332393384438633251253243217453314522213171123341
|
||||
3322333394423945242354443527243254144453523323423533223344254426635332443365444262334236433353624145
|
||||
5144363655544353445575456545535555553435557475538345539433254564335654546565526555535346264443556655
|
||||
4412333212122253112332322213222234222143332423432321112245112221351222222253323232332321222333225514
|
||||
3212222333233323121322222232232322322222242222321232223232232413312623341322221232223233333332222312
|
||||
4655445445664456554455544425246365545456565443544665558564474465663555525545635534355556553546655464
|
||||
2221222262232642433342264243612222222254241322526435265474324262242262225124422365221321532222154524
|
||||
2244433336631854623226311233223251314433322432662162666122313213414532223622223323213322546422123325
|
||||
4222312324252212332222243163152524432335321226244344335543522253343222457323243342432525242222421143
|
||||
2223412144354332412133131421325233214154422322322223722333232512232232222264544312122352221441252941
|
||||
2222221222122222231166235212214217222224221227372222222621824225245122264782122371422422335232432511
|
||||
2335334342152363523314422243422312212223332322222633242654124622542232252333244421322333332323523213
|
||||
3297973276668316426221924925275762549257228394533832343394336485363134743218173242447539267433384546
|
||||
2222222223241824142225222211232261221341411222325331212222124932222521262222262522322322312232224244
|
||||
5455444375585253144452424554354432563465462783446535754146493443556344763543324646447516433845365456
|
||||
7225186565757383564548236146446656162154835755533443468783467345345528846865233738243576443545572276
|
||||
2432421122244344436232458835283613273272427567343262433273623255234353365532232377243247762225352224
|
||||
2244342451422331233454232333223212312311311322383442232211321323342122213323223324312322143432432224
|
||||
2124143431323222541232225222831262336222224232324222152222213313222152232246222252241321243122532324
|
||||
1653932264143262633447653566243653172332634272456212343345236352214843653833315745321244346234693568
|
||||
4319388539655436758264786843998954433446458665333836836736414628834358479866434924575444337233445547
|
||||
2332231223223122222323232132233212233212234222222452122311132241223232332343322111312251321212322222
|
||||
4334224233223132312223235323241144632322423352522324241333313222232722243422222233322242332422321322
|
||||
7325143833445522342253575533545239454636574276452453545428245255572262258745258255454354382256551147
|
||||
4313428332343335133253313633363753222432332233333223332323723434364223323322222332332333222143433243
|
||||
5221121211554122623411335422212282122231242322432225222231274222222221214622142153252554222521322221
|
||||
2533453653533433392736235246324663763457254654283346375627342355332223273342643242236342734633533883
|
||||
2326222212232223211151222223272253222322312222113331222122322342232242222221222321122222222222222122
|
||||
3254324143436364232642544433433113754463332513334433382133427353556232328232343213563352335224252422
|
||||
5532336124222222122362223222331532245222452114229322142354133451222222225222222422222226346262114222
|
||||
3422333321332331222122212212122222323132213222333133332242415315232233334422222226223223122232712232
|
||||
6466753623243634686665566555555556355557555746645476598476241646166355284655667645578651566452676376
|
||||
2863222611313324322633232242323175743363253754241522221363826251688324435122232632233229595553333333
|
||||
2631233111213234235423624117353313342321331412232236313363532122713534332222638232343323223231252147
|
||||
5734565454654684242455752875976553556762545674431465458856453456455676355556642665623546935661758526
|
||||
2124241122142243325226342626232322442222331225222322441223224222113141221341221222322323222244512242
|
||||
3323363333335333333533333422153533332323343333133353333233355132623333243333333333323233333543434323
|
||||
4545332344521233543441821132432217333232244232243441433422234235444144223344442436353342244242813642
|
||||
2245923758623329723677234255242626666247532456252435328826343327323255732266648272923456765867424523
|
||||
4242291532296955862224621235693222398688563224642267272435923551221826272762227694597582694864322741
|
||||
4525587925524756326254523845567633246353344322646355766862772549423535466234795457673626979237357587
|
||||
3524846433553444343353453444363434435434444454344343344923334445343344335673454342334443344434442233
|
||||
8632541534343456944443234544136653215426833324325564653222554352446552339454613554345351352224452552
|
||||
4146136335256231436411256352635624365143261533236364343154432523235115664366615642155165465254523789
|
||||
3337736245234343333623443435363723345343534343634383323443536464133443524362323475553435333373454234
|
||||
2243332223561223133313332632353167233512223321222222262373312353422337333224222222331224233222322332
|
||||
3342542757535443656354333347363535753345534333748323566223343397533576647364333799332452333497334735
|
||||
6214212222222221221722423222282233322221321322232114725542222222324222214326272222322112112122323232
|
||||
4566422331332323636343525522334543323323224333366434353355255332433333323327323333533336353233313345
|
||||
4934444334224443372221124142644262554522744457423252263443334244444343254241357354442425444244434244
|
||||
3533348344333432323395883523342323533555649546624154416673456585151454523532567353929363642354224842
|
||||
3272221132643232822215223335523322212622393333432322222322423233132324328323223322951223334322323233
|
||||
2112622221212122222321221212422211222332251223332222363313122222322111321112324232722228272121113129
|
||||
3232523113123332333334231322321314263322131442422331323231323235332235325362312423223322534321321132
|
||||
9358556673766458329644599557567935658745257592867335543536146444655376355865957353876686234678366352
|
||||
5242223355523353224244441422243464324293371233324331534321421331422266422544235333234323433212338322
|
||||
4653544535233343446354247333541445343474243434444143415343444434446434444524374336434443343444554245
|
||||
3235533232523263225253363754561433453672725343534134563353661342643372341354333546566443434572133646
|
||||
3137934345454194326447323243223235254632424543945232242332331273362453447323238335823314153439633343
|
||||
2331232412262312322342322325313227322221622222176124215422231242122332221321222252713422217762621322
|
||||
3515124353432543135154424243432114341133552541554315213344351351553141444244535355115221354215426789
|
||||
2222222222223121112432132623144222214132252223222312331222222222221322222211222124322222181222234332
|
||||
2733222222212122218223325243113392232212227226222111241242232222212321223224322112232132222333321222
|
||||
7423253663522632216327236216426125525225336622341265352432225232222342252128632248522882222244423223
|
||||
5656839457566364549863875929783786563887555255788384646782785655752768663427235647423543444667545663
|
||||
2244224173242422144239447473244346231442242229441244124422561238512214226319427848248254394249239222
|
||||
3134324244123434411111341421211242342343321332244231123443213414121333144312141321414144241432456789
|
||||
2123222222532222331122223122122232122222282222352223152332321231223233322132223233212512221222222222
|
||||
3433337723687313343343341333333232233143333333333444326633324332322344333435732373333339332334344633
|
||||
4734552425421133624242225432756414442452344421683389322143423264864536194533224324143235262457432334
|
||||
5743642663548353363383344322233736237347332333663496653345433667377423173776724473546743337486434338
|
||||
6745464734746655363746438358445664347243384434547446379696644668564594954298936645584647643645765174
|
||||
5562557343335352722313258363233214252223526572225225223224641266122232332222116335672252525223512224
|
||||
5324226433351356545237253335433342535112223443325322434552591322233564453223344426491342444723513325
|
||||
2822323232432122331246221323232343332554293136122333138422323347433214333342132232242221233462232312
|
||||
3553334326333124133333333443313223333332333321325323333333423333324131233344332433233325343333334332
|
||||
3553328424442352323424221244423162245575433454736413256577364757365434564463335553523652256352344234
|
||||
4333423333322333233333331436323413243123352333623334333532342324242332521353623132232333533142332332
|
||||
2222235323113243332323253332263323232313333332332325333223422233223322242333123343333132222223333232
|
||||
5432334223333385363332322423354481633343433663433346341253542549375343333235363317433343343345273233
|
||||
1211122221212523421414252524222232212242522223222173212122222222233222251223212432122221222222232222
|
||||
5555341373369287553554338535578346252454585441333387475853443447548553955539636382737338684853648324
|
||||
3444423436833333536435333469436413441544344643358423523832535336444252855433235443347434334335334353
|
||||
4652433245373392351734541444434543592364584448349324446637446349426369323434633725425423434523353232
|
||||
1613212122723622242278212221272232412222223221222123223141422438212222321217383212222222524151328272
|
||||
2322312221422422243251342312132233222332232522132292212222421416224432224454211322142523242421242213
|
||||
2453552449355335353333455534312653322433129233223542244232317324523453324362443644654232245354535355
|
||||
3223432424314542311234346543245354543943325442344248556333321343354834323744433333325273223323236444
|
||||
3273322242922222234141213432233322333233323233223332331233321362321232132213232213221182122223213132
|
||||
4321354552542622325322616522523522526222253343721322354523641942223223225346435225323225616272146222
|
||||
2222132222222314211222121112121222222422412332512312212238221233253221213322222225231322322222223212
|
||||
3625623123174243241432662232234224452322223242162366253323442226423214114235521213214745343323445724
|
||||
2533233634253623433464437438242224623365332366323247348625873244236133936564534554336313622223133233
|
||||
8878788898777877487699888978898898777977877887887878896888888878889887889848788977988888888887598668
|
||||
3322373372422425244333245533554547334164541333434725333551323235552289432536533452254363344345231312
|
||||
1432436353334323233332333434434434433424332432323444344144364343344333333323243543333323344433453343
|
||||
3321443243342233121332332324222232332123333322232343123332343442222335114332322333333322212213223233
|
||||
2532352313412243222233523334241232345232323333312424323324232228332434414314322322135333233423343333
|
||||
6656264513224552455562413226315265366634632353552262256444251544424652563522513324454612351466422455
|
||||
3352334352963332363533134343333333333331733354223333334623335333332333343273513443333313333335523354
|
||||
7234732263333313357336744324735447533332634323323355352393353854644514337353133337532334948735433414
|
||||
8448646669263527951633858664544365767593846387636872455643647447578868665723215245346326842854666246
|
||||
2221322254222333253532212133222723212212241322223221222224323212222221222212121223111222231222211262
|
||||
1311333211332114227262347322122123232233222342227242633244212241214232121232342233132332222333228342
|
||||
2433433332444244212341442233154233443534424344443252433444434434432444323414342412342522233224444234
|
||||
2332233231464331642112543243233233321333362333542212223229243331222423322623331222724383423154246213
|
||||
3685536668666666766346582753666677876666572767446566666855463675556368366662476666652966456454677355
|
||||
1542215351142422327152324432222223322261222322114323522354322122262433432214242222241414222323352726
|
||||
3343413121222324251423224222122622143221233122324132222222421215121222412121412525311221242124252342
|
||||
2431163523214342142332232422413226164322332525241262222322223244236132224241222224224214264235323172
|
||||
8772463943137885373335252784576835477612752314166627355584276345334339636258711682416362866626727333
|
||||
1222222221421213222122273213222222222122622122225312225221122222132122322645422222621635224223112215
|
||||
3532213535352425264677454321235222442623242524167515217734513234215222242343961435525732355576335421
|
||||
3223214224342353422322222841224212214234222222933232633222455122323445332223455222223342651232421224
|
||||
7115343354233333232372323253132342221232232311226422321722136322525334224424223223321312222223333232
|
||||
4357663662356634546546765162524356556634434553343632666244395322153624565646225555345655566333465356
|
||||
2434343323323343342133252224322722324433333334422225233327143133352225134332374235484355434423321374
|
||||
1222252522232132523226226225267532752122243221523212222122224321337666223242631221222122242226252622
|
||||
2327332235127463626626621337227622858425364527752132212321323245321645326236343171423221625251761627
|
||||
5143312422222264523313532221243252242262241221552323712434423533212231135242225373522222333252243414
|
||||
2233873448923333213233237234315234232333333433353463333123337333633333332733322355224533333773372694
|
||||
6342346344334456623423254555234952146436432456242565674356553445434543524446245423534532524355535842
|
||||
3231222524241322342342223321233231332222634322332314231223212323232436223372353212431121252233352322
|
||||
4333335332232322233333231333232333333332354364223353434331233243323223533253632332333623513123322312
|
||||
2212212222223222321121322222321125232226121222222322222224221222222222322222221221222221232511212222
|
||||
3122221222121222544224224252252241122232222112223323231212134233131122224112214222225212222122232422
|
||||
3211356356222122215133526332233222322311255422224221241321336132223233242237246223926142867353622623
|
||||
2331443223411422242214536224213122324724332231312222222234322331132333313232222232322442631342122212
|
||||
2221335223943374316123324235452224332232224324331562434433253432121353332529322122244445424445254222
|
||||
6573934424747346565665565666563655546652665666364255554665696265663763456632338556367633652946366667
|
||||
2121122324322222212122232125111223322232124363222232311432332233211222312223313321232212213421322232
|
||||
5255884695277765342363572543544553876324623533752442343727423412433746382453326451584533733454633395
|
||||
3638831234162153683163343733723333358337317391373322323532733343162133633642433523433237486722337372
|
||||
1223333523332243233132232332232223335335322323525322321334253333332323332533333517335353454323533223
|
||||
4341437444333434323332333383423324432334353314128323534343344343334432154544343354162334333334354223
|
||||
3226222346642252223631222337433121222224221622216145222252232446252342322122222234222322222325222341
|
||||
2322154512252221221222213714342421221422226227211322247212222252224232222312312223421222234221532221
|
||||
4277666476564646666636626617632542654642124484356434552454644676322636365366654435524567623648665645
|
||||
4326224251324511325445265235322123123134324131225323445323442349342222222355534412243223435424754223
|
||||
2322222132112221222122212212222522252222722242222224214422222223264222222222252222233222222221112222
|
||||
2324232122242332222222242221332221213324334323232222412222222222222222224223222142222212222212321212
|
||||
5311236232323322323422313262214232324232532322334323342351243423323223336232323332331123223222222212
|
||||
3266355733331546543725353338633394673355295863352513444433679544569528558382293953841353213138855383
|
||||
5221322222122222722222362222222112747121221212222222331224721222422242221825322222252212222222517222
|
||||
1225242246213315532223222232331732223421223323116522132322122232231532233133121222822222462132133232
|
||||
2221326812226423812362221223211116525411823421279171513527321224217226242124244542225824262212224351
|
||||
4453425564443325353335233324434534363336223333422622636323343533343244433436456533432334323233334362
|
||||
3224232512141532361423211324223522252221342256222223212234123221322422322242321222232222247422253222
|
||||
6125122313322332232213332221223133535333332422313523321243243222232215243223221535432223335333234523
|
||||
1351678243754931425378943558344359229876853933447853352374345385533544635655973754647345363157934433
|
||||
4244122244422342343123435242374137343342123432243334242222123211312232244453344324374231231324554252
|
||||
2322353332422513334235125325633252242233252413323412222522323325155334324223233211523224223352123324
|
||||
5313436256323342326122534332142462233522466423222235523454546145825561325814532466226535435225486422
|
||||
5434443545444364645323442442456213744146245265734444415252259444643332333464442244443545345639431334
|
||||
76
03/main.go
Normal file
76
03/main.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func countJoltage(i int, rows *[][]int) int {
|
||||
totalJoltage := 0
|
||||
|
||||
for _, rowNumbers := range *rows {
|
||||
index := 0
|
||||
thisJoltage := 0
|
||||
|
||||
for digitPlace := range i {
|
||||
index = int(math.Max(float64(index), float64(digitPlace)))
|
||||
|
||||
for candidate := index; candidate <= len(rowNumbers)-i+digitPlace; candidate++ {
|
||||
if rowNumbers[candidate] > rowNumbers[index] {
|
||||
index = candidate
|
||||
}
|
||||
}
|
||||
|
||||
thisJoltage += rowNumbers[index] * int(math.Pow10(i-digitPlace-1))
|
||||
|
||||
index++
|
||||
}
|
||||
totalJoltage += thisJoltage
|
||||
}
|
||||
|
||||
return totalJoltage
|
||||
}
|
||||
|
||||
func main() {
|
||||
rows := strings.Split(loadData(false), "\n")
|
||||
|
||||
numbers := make([][]int, len(rows))
|
||||
|
||||
for ii, rowString := range rows {
|
||||
row := strings.TrimSpace(rowString)
|
||||
|
||||
numbers[ii] = make([]int, len(row))
|
||||
|
||||
for numberIndex, cc := range row {
|
||||
numbers[ii][numberIndex] = int(cc - '0')
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println(countJoltage(2, &numbers))
|
||||
fmt.Println(countJoltage(12, &numbers))
|
||||
}
|
||||
|
||||
func loadData(test bool) string {
|
||||
fileName := "input"
|
||||
|
||||
if test {
|
||||
fileName = "test"
|
||||
}
|
||||
|
||||
if cont, err := os.ReadFile(fileName); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return strings.TrimSpace(string(cont))
|
||||
}
|
||||
}
|
||||
|
||||
func parseInt(s string) int {
|
||||
if ii, err := strconv.Atoi(s); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return ii
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user