day04
This commit is contained in:
BIN
2025/go/day03/__debug_bin4231175632
Executable file
BIN
2025/go/day03/__debug_bin4231175632
Executable file
Binary file not shown.
68
2025/go/day03/day03.go
Normal file
68
2025/go/day03/day03.go
Normal file
@@ -0,0 +1,68 @@
|
||||
package day03
|
||||
|
||||
import (
|
||||
"adventofcode2025/utils"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const NUM_OF_CELLS = 12
|
||||
|
||||
func Part1(input string) int {
|
||||
var jolts []int
|
||||
batteries := strings.Split(input, "\n")
|
||||
for _, battery := range batteries {
|
||||
maxJolt := 0
|
||||
cells := strings.Split(battery, "")
|
||||
for i := 0; i < len(cells)-1; i++ {
|
||||
for j := i + 1; j < len(cells); j++ {
|
||||
jolt := utils.MustAtoi(fmt.Sprintf("%s%s", cells[i], cells[j]))
|
||||
if jolt > maxJolt {
|
||||
maxJolt = jolt
|
||||
}
|
||||
}
|
||||
}
|
||||
jolts = append(jolts, maxJolt)
|
||||
}
|
||||
sum := 0
|
||||
for _, jolt := range jolts {
|
||||
sum += jolt
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
var jolts []string
|
||||
batteries := strings.Split(input, "\n")
|
||||
for _, battery := range batteries {
|
||||
start := 0
|
||||
end := len(battery) - NUM_OF_CELLS
|
||||
j := ""
|
||||
for i := 0; i < NUM_OF_CELLS; i++ {
|
||||
v, pos := find_first_max(battery[start : end+1])
|
||||
j = j + v
|
||||
start = start + pos + 1
|
||||
end = len(battery) - NUM_OF_CELLS + i + 1
|
||||
}
|
||||
jolts = append(jolts, j)
|
||||
}
|
||||
sum := 0
|
||||
for _, jolt := range jolts {
|
||||
fmt.Println(jolt)
|
||||
sum += utils.MustAtoi(jolt)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
func find_first_max(s string) (string, int) {
|
||||
max := byte('0')
|
||||
pos := -1
|
||||
for i := 0; i < len(s); i++ {
|
||||
t1 := s[i]
|
||||
if t1 > max {
|
||||
max = s[i]
|
||||
pos = i
|
||||
}
|
||||
}
|
||||
return string(max), pos
|
||||
}
|
||||
20
2025/go/day03/day03_test.go
Normal file
20
2025/go/day03/day03_test.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package day03
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`987654321111111
|
||||
811111111111119
|
||||
234234234234278
|
||||
818181911112111`)
|
||||
require.Equal(t, 357, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`7455526631444542356445533352351453423842653536563363453344445222432533133425443346642463393231542655`)
|
||||
require.Equal(t, 893231542655, r)
|
||||
}
|
||||
200
2025/go/day03/input.txt
Normal file
200
2025/go/day03/input.txt
Normal file
@@ -0,0 +1,200 @@
|
||||
3238233422322723245312524333415334121333413432322532233243267325442232433333224143383436222223233233
|
||||
3655644666946277273684457436668666955664663983765757454464876854654654857865665766676664954456576457
|
||||
2222222214221321222242232252322221422222222212122123221322623222234222422221122212282121422123326322
|
||||
2124214643322332212222134232222223323244234222412424222132142344221221232224211124244142332242234423
|
||||
3436232236223426333625431396643366362565194162563644533454346253234235616323362232354352264323633232
|
||||
5222522242424132416252524213114222342315134433221233322222231246224242332433133211133213224152222532
|
||||
5426122223223222711223433222337222332222222833232224339146332213332173223213812332213383222132234312
|
||||
6754666344575335444575875747453663683596555517664555664546484534645635645553474345756556566654566656
|
||||
5433475435554344344375445374544445355635555544744477536637334335232664335527685544454753243246465444
|
||||
2533323723332334421324325274334254525431339343344558454433386313383333342332322853233331232763541433
|
||||
3434243341345332224133423322532152471432322626222426413335421225224211233163443935254725234333133342
|
||||
3541448771235152323243338633424215242426556266442614844233795554292323321243648444233424278324436324
|
||||
4232241923231442232233522224233222222232431222432321223233222123223234123233322133322222222322224341
|
||||
2322413333333323433423333323333431233331323233463333343333223323333323333323323333333332354333332133
|
||||
2212425414842355412223552127242426224852234212232212232222255523322321224232222232323222235222434633
|
||||
2222323222221122221215238122312222122214221322215512242233212223122222232412233122321222222271322222
|
||||
5215532261853227652345746126415532422366821723536247423754252265364642376432522655527226425574722471
|
||||
3222222422252332112231224221356222221223222134222221232223313326222222131432222522333222223122622222
|
||||
6676222427665466767653734672313657732795538736586768869694693597677586674659542276554762257672793343
|
||||
3653535256345253634345457434518545543444445544575534454455644555557475445545334555545353535563446555
|
||||
2233222222323144222222444222122411422321222212315431213323242223222222242233222224322232221212242531
|
||||
3424593117244244313425222742513498752244424152632323419112114524386212455225243275425565524227362317
|
||||
5531424542533424455635625443656442662633435324445245422523346364263544533554433452426246313433372514
|
||||
2522967564465922868445536669545363547885536537774684644666145884654894493744892656428549864924265585
|
||||
8736457373466777928237878853455465677654727936757338659679873668786246374673877537787726887267376752
|
||||
2962633343332244174633334533659659344458746512754522225623134372535234242564234635563533366423245423
|
||||
5534345333543743355425442536744453254445333225545543535344457451545632594543356384535385568433456583
|
||||
1222242782342223422232152131532242432823342274223223333234321212231233434122949312531515162212332222
|
||||
3434444332724222433423222345344859344234434244424222439432433414116164422214232344446376442441344422
|
||||
1222131622223342163222227222122143223242122222121212232322222226112222222221222222222252212222224251
|
||||
4262513533352222332233331225332231334153323333343383333133232834422433332433333343231743131343623232
|
||||
2555454275557549374368453564565154525643271535272434413352635365473535263236544335364434615263242555
|
||||
2132223355322342221432325223133355343253533434522435535322233332423232323244152221532243233455233213
|
||||
4333343123322333234342333333323333322322324231321332212223322333332323234332221332323311243233133313
|
||||
2332233333222334222442235222225322232322253234322231453222232241223133221323632233412254332224124244
|
||||
3441632222323232421248242763264244122234632343422122214222322222244421122442226222412431417242323342
|
||||
2343221313234232624432424245315522424236224523135333322124222312233232412231324422232221244343433431
|
||||
3343222224333332146373333536133223346235344317253322382322262522232642222242324443332123216233333336
|
||||
2322312242313222417322222222222216232212214122221242233233243122243212322223222232222221852212222312
|
||||
2223223341233323322432232212233323331231233213322232233322231334742823233312233134243223333133122813
|
||||
3228334576353333562327554733771334232485374333433542631274235374544691334331347733234373357337725333
|
||||
3454244353353733542724475534227534446346833483535544236532367313365345453652244346263533435345913544
|
||||
2246211242428262951721221182321231224644212222142422283351232222221262176382312228292322229224212222
|
||||
6431432336442565163354443334452545623333245524212534544624222324342356231541294462352313344454212354
|
||||
2252117225531222122221132222211222212222142223318712222127262222211222122422322212222242922222231312
|
||||
1123144213142231424531224423714253222543235421344223222121252523232422211142423222321624314221344422
|
||||
5232224422123225232122225112224241222222223215252312222321153231322223323222245523253328123222222551
|
||||
3621232222112263122322246123222323222222512232221321432423223272222142328132212121222121722217621221
|
||||
2214222412122212232321333262225222332232232227222242222222335335222223332222262222223532514222121223
|
||||
2444741342314432395654242442245546624556344421445142212345263223224343343424334485233344552235344253
|
||||
3333463433354333837333621424322336535344233323423838531653453683332523962234334133224526144314536364
|
||||
5233451445357625537562657759256372535254626263575665372569645126455436743347439353353254435432874561
|
||||
3663386342525234673448454446432334344423338533332433256344673633766354323333234733666733443363156993
|
||||
4646264122632272152731226385422122232389226213253536722212342532472422734255623435243713254142122416
|
||||
3324315533434373442757634653443532352441324226346363223259263334634127442224334414533372361535353625
|
||||
3123247753461326484274222842132361327344636382448381324233242757236332232212231414124233233873435132
|
||||
3233343222325533333253333344532433545334343153543345332342242432335532543365242334353225242142246234
|
||||
2233122341331332425544342454212321223425213335322342532322111224221332254222245232433433337242232311
|
||||
3634366254544744542544545363644446633443454444433454343444445442535455234542947463224644445635444433
|
||||
3633332723672391314313438632262276312226266642352226633983253547635125722222233222322926322577322232
|
||||
3349532424243225533432226342412622222355454427424444422423223514522514554332136332333124532332242453
|
||||
3322652426343223283633633453326532426128221533638567312453331214352342234233823343233331348433483233
|
||||
3263222324513843332311751222421122234213332433332233432222452233322223233232231222314232122413333346
|
||||
3324424543235445343532636425243343353347322733541434155245334643241125223435453448654645267683332472
|
||||
4234523123332252462334421551311512252533524623636312441222334223323142422752276162215723345522233424
|
||||
3453355424333343224433334444322836743342424333464334424342244444532744223434353439324346343134345443
|
||||
5232225334455644395443426443453336424533442322134345525242534235325326232332254333459253214434432564
|
||||
4323344383331322442312221213433424324423315127366323232352236343344337114672432324332542133443313334
|
||||
1764276943738333483449376253345367364323233372359752443954437338534536336432543736348373352783333548
|
||||
2332239223223854323335331223333383313233221523333228336232341351833392228333813353333132432338233323
|
||||
4583591334525833233466252342338345436334284343934424328652553552334233137558828333333482323533333745
|
||||
4233444624654525435643568366547136244562544465423332263526257467634235533338336334454535625566363266
|
||||
7152548554343414554436353216685221244535423895629554685556276432315645347364425558275323214283253454
|
||||
2421264125122232322422263243242143322542832641422542623222222234312242112672321232211432331256525423
|
||||
3452151314152322833231342345322332321332325731334515333322253125224452542121222641233122412326723521
|
||||
3223333523324343142123232222312322343214453442342321232244232232313424324242452234313221443212322314
|
||||
5455335555555244444343434356464535433565522544555544533435444535455454563751494555455525542312553642
|
||||
2532323522123514123223222362334223243315331623312522222332232566327213321322236133323352321232252211
|
||||
2223328233439225525461513372563325152332242222423331327722331422417422244522425251452226185433552133
|
||||
2222361253434322222324326322322573223432333333736363133233122352132233332333641323133312322223133132
|
||||
1226344252613414224222243423523423232134321332276321322234142322432427224252624232424332525226523222
|
||||
2252321212212225132232214262243322222521132222232122111222321221221222232242522121229221222412222222
|
||||
3112422332212244222132422321223121113323132223285222231111222324432262344212322223243222211223223232
|
||||
3223833132233332453422423333764133253133323332252225266362252326131253337333351413333314522222314332
|
||||
5223423222232512422633522223243143252433355433435243152432332224244352243415222332312334453521223332
|
||||
2333122244233465315224221212321234353232323336532422482322333112522422323624153222632331534322232224
|
||||
3231222242442232122232443314242222442223251242432222424122251512222442323524422422432242342313223344
|
||||
5644414434454344454443543383452425354534344244343858446444355554238543437342544643643345631355464355
|
||||
1232222332222332243322212212424322232323321323212223322232332131331332313225133332222342532512334323
|
||||
1125422227334692563222364233231324222323356241222463222274411354445223323221223523423337388626432965
|
||||
6225122321122223211424222214222712222242242222422243222222132211223222223421223334611222222122222222
|
||||
3645564444551544255548255454537635664556558585153955773356653554496365547554555454555423535344655555
|
||||
1343221246323622245222234442432224253426267241221242242442444262472422221321232744752242322632314632
|
||||
3232555333332354435335362634135123343356244234263316444276362432623333533533641533565535443255432634
|
||||
3335333333133123333233353233233353333323334252334332323443323335333332333333433332331334233224542352
|
||||
4676333533566746975628576749784694456766435483543573628547353567434736535766335667475674437754646756
|
||||
2242712275422321222222123312422224243221212214222221434231315221232112222222121224712222242123322211
|
||||
5232222113532224143221226251323324512122432423115322423221213222421232352654122252222432221522211221
|
||||
2324326227332323323532862322424313121233432131332213321223233253423222283334252232219222461333123233
|
||||
4638233763365656447356534356533563586353256748731467735514376457957325763695463546863356585443543874
|
||||
4341223424434414544235445342328633543233443454413422444432343354433212242334262372215412124162174444
|
||||
2326422519242433234222212432229723223323222322272642222323224241222452132242233142323222326431213229
|
||||
2223326632213632543326153452322572226456223517446532123552312254533353514633325153244532252125332415
|
||||
2548666542777567464423266492454544354454661745445344433867825595845487556474674534981345944556448496
|
||||
3655836499753458447557343546944375655847554565459678854745985557565559545786564587863495674374558454
|
||||
3272131532423362122223222322224622212282353323224321341281632222222528127232143262222222222262122122
|
||||
2323222636483639363543233522326412713366693834623222221262373242138544415536224232523552252434745421
|
||||
4576436326433332514343177135333415334462323434333633364617529635433436471434343574323543333534243333
|
||||
7673924444565367226382625746534735668736376676725229766887388769486869648253727666686455732798673765
|
||||
3242233522822433682823442441234512251142431642222244224352242172253256326332562448225246152424652223
|
||||
2212212132222222228121133322232212222122222222422222212221222232221222221222222222311232212221222232
|
||||
6466366554766673666845986646655556565666566546466763676654556666655756658655845534676566554257656666
|
||||
2524152234153624656232213316273225622342332147241252323725113232215222426521213342223232333354222368
|
||||
2223221222112512241122625222211322222213223222222222222312212222222121222142222211221222324322352222
|
||||
1142652163542323322533543552241232222544345356425364346176325632225132253835472375562224422524325536
|
||||
5392386646332728446732822143641788824676122643322647637183734251272163248735585358825328124247257556
|
||||
2222323133232232223222212232113633222222221633222212334222224332422243113332212522132322222122312231
|
||||
8683886678883624393276865368669575448493288727667228697234668168889838956386424374723775752657959836
|
||||
3533425634665614423437735633756435366347744722543444677523242286463445344134345754464253774437421336
|
||||
4463354424463534587843748445543473465646734545484353344345448664673433546735755553462345543244443443
|
||||
3333494444324354464344753344444434442642424441645245754424433343613243676696454445443236434745474443
|
||||
3334332433325432333124543334533333323553326334334483343323625345363333533333333333343453253342355266
|
||||
1432236233423212223212242223121222252252212312221212762122212232322212323242235322211432422222224322
|
||||
3333256463413233344333333312633332333325453422324333392463463322433225353231334433353243323444333333
|
||||
7736237745293832739263726338732559784369673833547354558664757444786583187833223136867423585569516866
|
||||
1131142332334142214421311222143312133214121223313231113442421334232144444222434113313432133424156789
|
||||
3232124235342282623122252222373334433336322328113723262283353333823268352326382427242736332935222631
|
||||
4468556567768676565885994797565466448385756746485674257645947658644358697757959999496265554795754628
|
||||
2575245654587756544544555344325445444253846472736554654944456444532452574557457754455533455716351349
|
||||
1449228731625783546145322282376767945223354784761591623444944679322296782334427733195467724784774276
|
||||
2423643333337342333443333443333223333223346534343343634333534463723344313232423443333333243444143325
|
||||
3335433461436335223245436411433353533346463835374345434473722236532435335542455353323333377788217332
|
||||
2333423523644253232534232641334254632223332955423322342335543262329423753433432543282382132331333323
|
||||
3244233433334443424441433434444534331244434432333323433414343334243433333434423224334334332434333433
|
||||
6362712672268282283761924427141563687696283521585244925674622472623724287874234626273255264425238433
|
||||
5328341233214483581323225524443336235432243422416445223334234212623234324243622412332523332443531452
|
||||
3637386345347745474463377423675454654368458535577555336134534368354335444343774333474342353954334455
|
||||
4434644244265424543324753622464334553552134445344662544355363441242264543543344425444645544434464446
|
||||
3223212233353232233322333339364223224354221333223233543242213332331222243424322213322133134332333331
|
||||
3153332553335544459766263375645636357666454552552332634752646655261553677536455646676626535362454335
|
||||
5473534221354325227446257652544438222494273862536522244571444476228542225343361292447541154453339474
|
||||
2221224222412325222534221221431233522264323422233352422222231322244442232223232225423242263232552343
|
||||
5332427364273242312934243526733672664424442218537634449366534313935634536814632433225563842264427242
|
||||
6235266277265342456137175322124157375434143165657145451146775315575231444663125462654744375531134289
|
||||
3421222675734234317233291215315253432642242377222257341342223228582427172712135272254627136261223634
|
||||
5433432112325134322333333233212322113333132322243423344352242233413143221311322442322313241245332221
|
||||
3423734435853334374537836333333333317433352683453443353785482319323532251323373393833533838862838333
|
||||
5657323833536351353333363782336373322831333642333243533331333328332333353233285222557336315323313364
|
||||
2442519326432623532344727393285833347123418565397636331334347245722384632864525658762677744314646333
|
||||
4125132521333231232235325331322342325622223234122792354213323311343523232323513253493324352496461423
|
||||
3362421473222221213315222122344245222332224252326272222233232223321122235226142321223231326313224262
|
||||
3732354133363432432423713233832433328234144313334323734464244363423672452673398233733263233338332332
|
||||
3767773886665564214526315412774737756177467576263358827536626878161412332417831532815537625153423729
|
||||
5521353234533542595546884224253243311325323554357328942323262343928222538322263522364222442233333513
|
||||
2122322414223533222473242424222413224345321522325224322233424513224423322265123243112323352122333232
|
||||
7483463487356554736635846165545667958374844736734327464437954584362574727377684673345568765357378597
|
||||
2223232322112222262322322222223231422232232138221132212222221222213211221422223221321122111312126322
|
||||
3366233325237424446412434433264222422124255734432634244335324412245234313132252455237262464232345253
|
||||
4632413335342647253154534151123228132631386328422413224472722724124342692236632614222343373223423233
|
||||
3342342323422353444442211123321342434233724244422661444243432722422232322335141331341534432231731331
|
||||
7432225572522677423322272674452522724824325224215725322516323534252222823224553583222223552526274681
|
||||
6564655556755655663744565365543666448665653225365335532354433635744424842635386541465356658353534585
|
||||
1131244223511213433154353112523334432223215444342241233422145422553442224323331354313244212522426789
|
||||
1111213122221322123222222222522212147228223621223212221222292312212231212121222222212231211222522222
|
||||
2231621272211225174214132224132343252231425544532282456435473144273127234233623632443512324484121493
|
||||
2121243212342132322231232321322151244424133442362222324422232121424122332112222233313421412322213232
|
||||
2165314643441353632241614323463656325426665666531632561352152353513121235251663454652635354134356789
|
||||
2475231214243222622422128232222142342334542525221442122264428122222445212442812222331313922242222331
|
||||
3223323354333323234372444242373463821436122221823232432533533332344446513142323333541222341244217455
|
||||
7455526631444542356445533352351453423842653536563363453344445222432533133425443346642463393231542655
|
||||
8653953554777855947635356623955473553347535456542373216442635855766435335778333435863355534534696334
|
||||
2123313323533233522234325253134223134342463263454131142213134333334342242414333242344253333223253576
|
||||
4433351364335323163334323233734633344234343533524223331454334134343345333444333552324335333343135322
|
||||
2676247333884956267277436553754385673228458733632722367132455754724742672592656787535922265428847452
|
||||
5323342343344336454433333263423311328341322515255533364322646234565644344713216323855642632233565373
|
||||
1133221326942423244343323212222522121122242234221225552555243122222312226242322423242232122444161112
|
||||
5745757585647764645595455547777555574756775757484475665467555762654756556574765346685567548956663759
|
||||
4571321513255225214645223224114322318122222133446333321233692233524333646292412121393432285264282222
|
||||
3315332122322222252323332342321332263332143133412214123234344222242232422421243212314333132222424435
|
||||
3712452322745236234223432424523225472154354252623312322322292124423152214233272422452233312342222123
|
||||
2122122322222323222222212212222222332221213623222211262522221222212222212222121122224222222222111221
|
||||
3878463445456594343447696625474456434384664578488543373834987437558867455385835783452453584558746285
|
||||
8227231432234323326226222222223372233534224124232221133433311232252143422323253144252323242443131223
|
||||
3132233422232215222221112223612232536153612126257222232312223242621262223332122326225212331248125352
|
||||
8899389687567746688684992465866799836886577885757998968855448995658978853857785665776749875746666754
|
||||
6475176885462947335537363373673946483735476343335337376275334622583395356234523457624566667937332358
|
||||
5224457327442414324723564554424233627423444241443524344435827527429432834214343559324444555454761422
|
||||
4345325324355364334338464343241431247363234433363424532466863333432433643343475452322533364254343431
|
||||
5625893313532515654777281766549484453214439528733524862827285532721155253735432342894254445442515426
|
||||
2122223322323322233323333223313252222332324223123133413222233233323314213333222523332334223636232232
|
||||
3566454444795375834465668434645852632845467948764654464536444457635457666446253333457744448568467955
|
||||
3332274361452133542353243425423322231353344222151231312224534225344533323512113225552346234224515122
|
||||
3354332242433513337253337122133125323366332332223232244315522724231444323232633334123733113142742332
|
||||
1623223222222531261632222222222122122132143453212312262623222212222522112122223723222232225514326145
|
||||
5436354633654663574759344344656465454835454465474656557565544645346443956474444444954284444443734465
|
||||
5429583223625147865243782836886657435836657243263351643255252433652481223336266125523653422527977354
|
||||
3333221212323232323322224222224222232323233222233232212223322232232123122323222323323123233242273222
|
||||
2312322223223323122223323243322233333123322224331223133421423222331223343245423333234322422321233322
|
||||
5526855555441556453553354355557545724544436564664664877456643366453637585245747634666665454447345764
|
||||
2231312322221222122222221343522122112222225222123221221221221232222222242231112122222221221121222311
|
||||
92
2025/go/day04/day04.go
Normal file
92
2025/go/day04/day04.go
Normal file
@@ -0,0 +1,92 @@
|
||||
package day04
|
||||
|
||||
import (
|
||||
"adventofcode2025/utils/grid2d"
|
||||
"adventofcode2025/utils/inputs"
|
||||
)
|
||||
|
||||
func Part1(input string) int {
|
||||
adj := 0
|
||||
rolls := 0
|
||||
grid := inputs.ToGrid2D(input, "\n", "", "", func(c string) string { return c })
|
||||
directions := [][]int{{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {-1, 1}, {1, 1}, {-1, -1}, {1, -1}}
|
||||
for j := 0; j < grid.SizeY(); j++ {
|
||||
for i := 0; i < grid.SizeX(); i++ {
|
||||
if !checkChar(i, j, grid, "@") {
|
||||
continue
|
||||
}
|
||||
for _, dir := range directions {
|
||||
x := i + dir[0]
|
||||
y := j + dir[1]
|
||||
if checkChar(x, y, grid, "@") {
|
||||
adj++
|
||||
}
|
||||
}
|
||||
if adj < 4 {
|
||||
rolls++
|
||||
}
|
||||
adj = 0
|
||||
}
|
||||
}
|
||||
return rolls
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
grid := inputs.ToGrid2D(input, "\n", "", "", func(c string) string { return c })
|
||||
rolls := countRolls(grid)
|
||||
total := rolls
|
||||
|
||||
for rolls > 0 {
|
||||
removeRolls(grid) // modifies grid
|
||||
rolls = countRolls(grid) // compute only once per loop
|
||||
total += rolls
|
||||
}
|
||||
|
||||
return total
|
||||
}
|
||||
|
||||
func checkChar(x int, y int, grid *grid2d.Grid[string], c string) bool {
|
||||
if x < 0 || x >= grid.SizeX() || y < 0 || y >= grid.SizeY() {
|
||||
return false
|
||||
}
|
||||
if grid.Get(x, y) == c {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func countRolls(grid *grid2d.Grid[string]) int {
|
||||
adj := 0
|
||||
rolls := 0
|
||||
directions := [][]int{{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {-1, 1}, {1, 1}, {-1, -1}, {1, -1}}
|
||||
for j := 0; j < grid.SizeY(); j++ {
|
||||
for i := 0; i < grid.SizeX(); i++ {
|
||||
if checkChar(i, j, grid, ".") {
|
||||
continue
|
||||
}
|
||||
for _, dir := range directions {
|
||||
x := i + dir[0]
|
||||
y := j + dir[1]
|
||||
if checkChar(x, y, grid, "@") || checkChar(x, y, grid, "x") {
|
||||
adj++
|
||||
}
|
||||
}
|
||||
if adj < 4 {
|
||||
grid.Set(i, j, "x")
|
||||
rolls++
|
||||
}
|
||||
adj = 0
|
||||
}
|
||||
}
|
||||
return rolls
|
||||
}
|
||||
func removeRolls(grid *grid2d.Grid[string]) {
|
||||
for j := 0; j < grid.SizeY(); j++ {
|
||||
for i := 0; i < grid.SizeX(); i++ {
|
||||
if checkChar(i, j, grid, "x") {
|
||||
grid.Set(i, j, ".")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
35
2025/go/day04/day04_test.go
Normal file
35
2025/go/day04/day04_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package day04
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`..@@.@@@@.
|
||||
@@@.@.@.@@
|
||||
@@@@@.@.@@
|
||||
@.@@@@..@.
|
||||
@@.@@@@.@@
|
||||
.@@@@@@@.@
|
||||
.@.@.@.@@@
|
||||
@.@@@.@@@@
|
||||
.@@@@@@@@.
|
||||
@.@.@@@.@.`)
|
||||
require.Equal(t, 13, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`..@@.@@@@.
|
||||
@@@.@.@.@@
|
||||
@@@@@.@.@@
|
||||
@.@@@@..@.
|
||||
@@.@@@@.@@
|
||||
.@@@@@@@.@
|
||||
.@.@.@.@@@
|
||||
@.@@@.@@@@
|
||||
.@@@@@@@@.
|
||||
@.@.@@@.@.`)
|
||||
require.Equal(t, 43, r)
|
||||
}
|
||||
140
2025/go/day04/input.txt
Normal file
140
2025/go/day04/input.txt
Normal file
@@ -0,0 +1,140 @@
|
||||
@@@@@@@@@.@@@@@@@@@.@.@..@@..@@.@.@@.@@.@@@@@@..@@..@.@.@@..@.@.@@@@@.@@.@@@@@@..@@@@@@@....@@@@@@@@.@.@.@@@@@@@@@@.@..@@@@@@@@@@@@@@@@.@.@@
|
||||
@@@.@@@.@@@@@@..@..@@@@.@.@.@.@@@@.@.@@@@@@@..@@.@@.@.@@@@.@@@@@@.@@@@.@.@@@...@@.@@@@@@.@.@@@.@.@@@@@.@@@@@@@.@@.@@@@@@@@.@..@@@@.@@@@@@.@@
|
||||
@@..@@.@@@.@@@@..@@..@..@@@@@@.@.@@..@@@@....@@@@@@.@.@@.@..@@@@@.@@@@.@@@@@..@@@.@@.@@.@@..@@@@@@@@.@@@@.@@@.@@@@@@@@@@.@@.@@@@.@@@..@@@.@@
|
||||
@...@@.@...@@@@@@.@@..@@@@@@@.@...@@@@.@.@@...@@@.@@@@@@.@@@.@@@.@.@..@@@@@@@@.@.@@@@..@@@.....@.@@@@..@...@.@@@@@..@@@.@@@.@@....@.@@@...@.
|
||||
..@@@@@.@.@@.@@@..@@@@@@.@@@.@@@@.@@@@.@...@@@@@...@.@@@..@..@..@.@.@.@@@@..@....@@@...@@@@@.@@.@@.@..@.@@@..@@@@@@@@..@.@.@@.@@@..@@@..@@@@
|
||||
@@@.@@..@@.@@@..@@.....@@...@@@.@.@@@@@.@@@@..@.@@@@.@.@@@@@@.....@@.@@.@..@@@@@@@..@@.@@..@@@@.@@@.@..@@@.@@@@.@@@.@@@.@@@@@@..@@@@@@.@.@..
|
||||
.@@@@.@.@..@.@@@@...@.@..@.@@@.@..@.@...@@@.@@..@..@...@@@..@@@@.@@@.@@@.@@@@.@.@...@@@@.@..@@@.@@..@.@.@@...@.@@.@.@@.@.@.@@@@.@@..@@@@.@@.
|
||||
.@@@@@@@@@@@...@.@.@@@.@@.@.@.@.@@@@@@@.@@.@@@......@.@@.@@@.@@@@...@@@@@@@@@@@@@@@@.@@@.@@.@..@@.@@@@@..@@@@@@...@@@.@@@.@.@@@@.@@@@@@...@@
|
||||
@..@.@@.@@@..@@@.@@.@@@@@@@@@@@@@@.@....@...@@.@@@..@@@@.@@@@@@@@@.@.@@..@@.@@@.@.@.@@@.@.@@@.@@@......@@@@...@@.@@@@.@.@@@.@.@@..@@@@.@.@@@
|
||||
@@.@..@.@@@@@@@@.@.@@@@@.@.@.@@.@@@.@@@@@@@.@@@@@..@@@@.@@@@@@..@@@@@@..@.@.@@@.@@@@.@.@@.@@@.@@@@.@.@@...@@@@@@@.@@..@@@@.@@@.@@@.@@@@@..@@
|
||||
@..@.@.@..@.@@.@@@.@..@@@@.@.....@..@@@@@..@@@..@@.@@@@@@.@@@....@@..@@@@@@@@@..@@@.@@..@@@.@.@@@@@.@@.@@@..@...@@.@@@..@.@.@.@@...@@.@@@.@.
|
||||
.@@@.@@.@@@..@..@@.@.@@@@@@.@.@.@@@@.@@@@@@@@..@.@@@@@@@@.@@@@@@@@@@.@@.@@@...@@.@@@@@@@.@@@.@..@@.@....@@.@@...@@.@@..@.@..@@@@..@.@@@.@..@
|
||||
.@.@@@.@@.@..@.@.@.@@.@.@@...@.@@.@..@.@..@.@@.@@.@@@@@.@@.@.@.@@@@@@@@@@@.@@@@@.@.@@.@@@.@.@@@@.@@@@.@..@.@@@@@.@@@@@.@.@@@.@@@.@@@@.@@.@@.
|
||||
.@@..@.@@@@.@@@@@.@@@..@@@..@...@@@@@@.@.@.@.@@@@@@@.@@..@@@.....@@.@.@@@..@@@@..@@@..@.@@.@@@@@@.@@@...@...@@@@.@@@@@@@@@..@@@.@.@@.@@@@@..
|
||||
.@..@@.@..@@@@@@@@@@@@.@@@@.@..@.@@@......@@@@@@.@.@..@@.@.@@.@.@...@.@.@@@@@@.@@@.@@@@@@..@.@.@...@..@@.@..@@@...@.@@@..@@...@@@@@@@@@..@..
|
||||
@@.@...@@@@.@..@@.@@@.@@@.@.@.@.@.@.@.@@.@@@.@.@@@@@.@@@..@@..@..@@@@.@.@@@.@@.@.@@@@@@@@@.@.@.@.@@@@.@@@.@@@@.@@@.@..@.@@@@@@@.@@..@@@@..@@
|
||||
@@.@@.@@.@@@@.@@@.@@@.@@@@...@@@@@@@@@.@@@.@@.......@@@..@@.@@@@@@@@...@@.@@@@@@@@@.@@@@@@@@.@.@@@@.@.@@@@@.@@@@@.@.@@@.@@@@@@@@@.@@.@.@@@.@
|
||||
.@.@@@@@@@@@.@@@@..@.@.@.@@@@.@@@@@.@@....@.@.@.@@..@.@@@@@.@@@@@@@@.@.@@...@@@.@@@.@@@...@.@@@@@.@.@.@@@.@@@.@@@...@@.@@@....@.@@@@.@@@....
|
||||
@.@@@.@@.@@@@@@@@@@.@@.@@@@@@@@@@@.@@@@@@@@@@@.@@@.@@.@..@.@@@@.@.@.@@.@..@@@@.@@@@@@@..@@@@@@@@.@.@.@@@@@.@.@@@@@..@..@.@.@@@.@@.@@@@..@@@@
|
||||
.@...@@@@..@@@@...@@@@...@@@@.@...@.@@.@@@@@.@.@@@.@@@@@.@.@@@@@@....@@@@@@....@@@@.@.@@@@@@.@@@@@.@@.@..@.@@@@...@@@@@@.@..@@@@....@.@@.@@@
|
||||
..@.@@@..@@@@.@@@@..@@.@@....@@@@.....@.@.@@@.@.@@@.@@@@@...@@@@@@.@@@@@..@@.@@..@@@.@..@.@....@@@.@.@.@.@@.@@@@@@@.@@@@@@@@.@.@.@@@..@..@.@
|
||||
.@.@@@@@@@@@@@..@.@@@@.@@.@@@@..@...@..@@@.@.@@@@...@.@.@@..@.@@@@@@@@.@@.@.@..@@@.@.@@...@.@@@@..@.@@.....@.@@@@@.......@@@@@..@@@@@@@.@.@@
|
||||
@@.@.@@@@@@@@@@@@.@@.@@@@@@.@@@.@.@.@@@@@@@.....@..@@.@@@@.@.@@@@@@.@@...@@.@@.@@@@.@.@....@...@.@.@@@@@@.....@@..@.@.@@.@@@@...@@@@@.@@@@@@
|
||||
.@@@@..@@@@@@..@.@..@.@@.@...@@@@.@@@.@@.@@....@.@@@...@.@@....@.@@.@@@..@@@@.@@@@.@..@.@.@@@@.@@@@....@@.@@..@@@@@@.@@.@@.@..@@.@.@@@....@@
|
||||
.@@.@@.@@@@@@@.@@@@@@.@@.@.@@@.@@..@.@@.@.@@@@@@.@@@.@@@@@@@@.@....@@@@@@..@...@.@.@@@@@@@.@.@@@@.@.@@@@.@@@....@@@@@@.@@@@@@@@@.@@@.@@@@@@.
|
||||
@...@@@@@@.@@@.@..@@@.@.@@.@@.@@@@.@@@...@.@@@@@@@@@@@..@@@..@@..@@.@.@@.@@@@@@@.@@@@@.@@.@..@@.@@...@@@..@@@@....@@.@@@@@@@@@....@.@.@.@@.@
|
||||
.@.@.@@@@@@@.@@.@.@@.@.@@@@.@@@..@@@@@@.@@@.@@.@@@@@.@..@@@@.@@@...@@@..@..@@..@.@@@@@@.@@@@@@.@@@@@.@@@@@..@@@.@@@@.@@.@@.@@@@@@@@@...@.@@@
|
||||
@.@@@@@.@.@.@..@.@..@..@.@@@@@.@@@@@@@@@@.@@@@@@@.@.@@.@@@@@@..@@.@.@@@.@..@.@@@..@.@@@.@@@..@@@.@@@@@@.@@.@@.@.@@@@..@@@@@@@...@@@@@@...@@@
|
||||
.@@@@@@.@@@.@@.@@@..@@.@@@@@@@.....@@@@.@@@@@@@@.....@.@@@.@@@@@@@..@.@@@@..@@.@....@.@.@.@@@@@@@@.@..@..@..@@@@..@@...@@@.@@@@..@@@@..@@@@.
|
||||
@@.@@@@.@@@@@@.@@.@@.@@@@@@@@@@@.@@.@@..@@@@.@@@.@@.@@@@@.@.@@@@@@..@@@.@@@@@.@@.....@@@.@@.@@@@@@@@.@@@..@@..@@.@@.......@.@@@@...@@@@.@@..
|
||||
@.@.....@@@...@@@.@@..@.@@@@@.@...@@.@@.@@@@@.@@..@@@@@@@@@@@.@@@.@@.@@@@..@...@@@..@@@.@.@.@.@.@@@@..@@....@.@..@.@@@.@..@....@.@@.@.@.@@@@
|
||||
@@.@@@..@@@@@.@.@@.@@@@@@@@.@..@@@@..@@@@@@..@.@@.@@@@@@@@@@@@@..@@.@@@@.@@.@@.@@@.@@.@.@@@@@@@.@@.@@.@@@@@@@.@@....@@@...@@@@@@@@@..@@.@.@@
|
||||
@..@..@@@.@..@@@@...@@.@.@...@.@@.@.@@.@.@.@.@@@@@.@.@@@@@@@@@@@..@@.@.@..@@.@@.@@.@.@.@@.@@.@@@.@@@..@..@@.@@.@@@@..@...@@@.@@@.@.@@@@@.@@@
|
||||
@@@.@@.@.@.@@@@@.@@@....@@@@@@@.@@@@.@@..@@@@@@.@.@@.@.@.@@@.@.@@@@@.@@@...@@@.@.@@...@.@@.@@@@..@@@@.@.@..@@@@.@@.@@@@@@@@@@..@@@@.@@@.@@.@
|
||||
@@.@@@..@@..@.@@@..@.@@@@@.@..@@@.@.@@.@@.@@@.@@@@@@.@@.@@.@@@@.@.@@@@@.@@@@.@@.@@@.@@..@@@@.....@@@@.@@@@@@@.@@@.@@.@@@@@..@@.@@...@@@@@@.@
|
||||
@@@@.@.@@@@.@@.@@@@@..@.@@@@.@@.@.@@@@@@.@@.@@.@@.@@@.@@.@@@.@@@.@@@...@@@@..@@.@@@@@@@@@..@@@..@.@.@.@@..@@.@@@@.@@@.@.@@@..@@@.@@@@@@@@@.@
|
||||
@@.@@..@@@.@@.....@...@@@.@@.@.@..@.@.@@@@@@.@.@@.@.@.@@.@.@@@@@@@@..@@@@.@@@.@.@@..@.@.@@@@@@@@@.@@@@@@.@.@..@@..@...@......@@@.@@.@@@@@@@.
|
||||
@@@@..@...@@@@.@@@@@@@@.@@...@.@...@@@@.@@@@@@@@.@@@..@@.@@@@@.@@@@.@.....@@.@@.@.@..@.@@.@@@@@.@@@@@.@@@@@@@.@@@@..@@@@@@@@..@..@@.@@.@.@@@
|
||||
.@@@@@@.@@.@@@@@@@.@@.@@.@.@@....@@.@.@@@@@@..@@@.@.@.....@.@@@@@@@@.@@@...@.@@.@.@@@@@.@...@@..@@.@@@@..@....@@@..@@@..@..@@@@@.@@....@@..@
|
||||
@@@.....@.@@@@@@@@@.@@@@@@@@.@.@@.@@@...@@@.@@@.@@@@@@@.@@@.@..@@@@.@@@@@.@@@@.@@@@.@@.@@@@.@.@@@.@..@@@@.@@..@@.@.@.@@.@@..@@.....@@@@@@@.@
|
||||
@@@...@.@@.@@@@..@@@@@.@@@@@@@...@@..@@@.@.@@@.@@..@@@@.@@@@.@@.@@..@@..@.@@@@.@@@..@@@@.@@@@.@@..@@..@.@@@.@..@@@@@@@.@.....@.@.@.@..@@@@@.
|
||||
..@...@@.@@@@.@.@.@...@@..@@.@.@@.@@@.@@@@@@@@.@.@@...@.@@@@@@@@.@.@@@@@@@.@@@@..@@@@@@@@..@@@@@@.@@@...@@@@..@@.@@@..@.@@@@@@@.@@@..@@@@@@@
|
||||
.@.@.@.@@@@@@@@.@@@@@..@@..@@...@.@.@@....@@...@@@....@@.@.@.@@.@@.@@.@...@@@...@..@.@.@.@.@@@.@@@.@@.@@@@@@.@...@.@@@@@@.@@.@.@@@@@@@@.@@@.
|
||||
@@@..@@.@@@@@.@.@@@.@@@@..@....@..@@..@@@.@.@@@.@@...@@.@@.@.@@...@@@.@@.@@@@@.@.@.@@@.@@.@@@...@@.@....@@@.@@@.@@.@@@@.@@.@.@@@@@@.@@...@@@
|
||||
@@@@.@.@@@@@@.@@.@@@@@@@@.@@@@@@@@@@.@@@@.@@@@.@@@.@.@@.@.@@..@@.@.@@.@@@..@@.@...@@.@@..@@@@.@@.@@....@@@...@@.@..@@@@@.@.@.@.@.@@.@@@.@@@@
|
||||
@@@@@...@@@@.@.@@..@@@.@..@@@.@.@.@..@@@...@@.@@@..@@.@@..@.@@@..@@@..@@@@@...@@@@@.@@@...@@@@.@.@..@.@.@@.@@@...@@@@@.@@..@@..@@@.@@@@..@..
|
||||
..@@@@..@@@@@@.......@@..@.@@.@@@...@@.@@@@@.@@@@.@...@@@@.@@.@@.@@@@.@@.@.@.@@@.....@@...@@@@.@@@..@@@.@.....@..@@@@...@@@@@@..@@@@@.@..@@@
|
||||
@.@@@@@.@@...@.@@@@@@@@.@@@@@...@.@.@@@@..@.@@@.@@@.@@.@@.......@@.@@@@.@.@@@@@@@.@.@@..@@@@.@.@@.@@@@@..@@@.@.@...@.@@..@@@@@@.@.@@@...@@..
|
||||
@@@..@......@.@@@...@@@@.@..@@@@@@.@@@..@@@@@@@@@@@@@.@@@@@@@@@.@.@..@.@@@..@.@.@.@@@@.@@@@..@@.@@..@..@@@@@@@@@@@@@@@@@@@.@@..@@.@@@@@@@@@.
|
||||
.@@.@@@@@@@.@@.@@@@.@.@..@@@@@..@...@..@...@@@@@@@@@@....@...@@..@@@.@@.@@@@@@@.@@...@@@@.@@@@..@...@@@.@@.@.@@@@@@@.@.@.@@@@@@@..@.@..@@@..
|
||||
@@@..@..@@.@.@@@.@@@.@@.@@@.@.@.@.@@.@@@@..@@.@.@@.@..@@@@@@.@@@..@@@@@@@@@.@@@@...@@@@@@.@@@@@.@...@@.....@.@.@@.@.@.@@@@@@@.@..@@@@.@.@@.@
|
||||
@@@@@@@@....@..@.@@@@.@@@@.@@@@.@@@.@@@@.@@@@@@@.@@@@.@.@.@@@@@@..@@@@@..@@@@.@.@@@@@@.@.@.@@@....@...@.@.@.@@....@..@@@@@@@@@@@@@@@@@@.@@@@
|
||||
@.@@@@@@@@@@...@@@.@.....@.@@@..@@.@.@@.@.@.@@@@@@@@@@@@.@@.@@@@...@.@.@@.@...@@@@..@@@@@@.@@@.@.@@@.@@.@.@@@@@@@@@.@@@...@@@@@@@@.@@@.@@@@@
|
||||
@@@.@.@@@.@.@@@..@@@..@@@.....@.@.@@@@@..@@@..@@...@.@.@@.@.@@@..@..@@.@.@@..@@@..@@.@@@@..@..@@.@@@@@..@@@@@@.@@@@@@@@@.@@@@...@@..@@@@@@@.
|
||||
.@.@@@@.@@@@@.@..@@@@....@@.@.@..@@@.@@.@.@.@.@@@@....@.@@@@...@@@@@@@...@@.@..@@.@@.@.@@.@.@@@@@.@.@....@@.@@@.@.@@...@.@@@@@@@.@@.@@@...@@
|
||||
@@..@@@..@@@@.@@@@@..@.@@.@@@..@.@@@@@@@....@.@@@@.@@..@@...@..@@.@@@.@.@@@@.@@@@.@@..@@.@@@@...@@..@@@@@@@..@@.@@.@@...@@@@.@@@@.@@..@@@@.@
|
||||
@..@@.@..@.@@@...@@@@.@..@@@.@.@@@@@.@@@.@@@@.@.@.@..@@..@@@.@@@@@...@@.@..@@@.@..@@.@.@@@@@@@@@@@@@@@.@@@@@...@@@.@@.@@.@@@@@@@.@..@.@@...@
|
||||
@..@..@@@.@.@@@@.@...@@@..@.@@@@.@@@@.@@@.@@.@@@..@@@.@@@.@@@@@@.@.@@@@@@@.@@@..@@.@.@@..@@..@@@@.@.@@@.@@@.@@@..@..@@..@@@@@...@@@@....@@@.
|
||||
@.@.@@@@.@@.@@@@@@@..@..@.@@@@.@.@..@@@@@..@...@@@..@@@.@.....@@...@..@.@@@.@@..@@.@.@@.@@@@@@@@@@.@.@@.@@@@......@.@.@.@@.@.@@.@@@@@@.@@..@
|
||||
@.@.@.@@@@@@.@.@@@@.@@@@.@..@@@..@@@@@@@@@@.@@.@@@@..@.@......@.@.@@@@...@@@@@@..@.@@@@@@@@@@@..@.@@@@@.@@.@@@.@@@....@....@@@@@@@.@@.@@.@@@
|
||||
@@@@@.@@.@..@@@@@@@.@@.@@@.@@.@@@@@@..@..@@@@@@@@@.@@@@@@@.@@@@..@@@@..@@..@@@.@@@..@.@@@..@@@.@.@@@@@@@..@@.@@.@@@.@@.@@@.@@@@@@@@@@@..@@@@
|
||||
@@@@....@.@.@.@.@.@@@@@.@@..@@@@..@@@.@@@@@@@@@@...@@@..@@@@..@@@@@.@@@.@@.@@@@@.@..@....@.@.@@@...@@@@.@@@@@@.@@.@@@.@@....@.@@@@@@@@...@.@
|
||||
@.@@.@...@.@@@@@..@@@@.@@@...@@@@@.@@@.@....@@.@@@..@..@@.@.@@@.@@@...@@@.@@..@.@@@.@@@@.@@..@..@.@..@...@@@@...@@@..@..@@@@..@@.@@..@@@@@.@
|
||||
@@.@@.@@@@.@@@..@@@.@@.@@@.@.@...@@.@@@@.@@...@.@....@.@@@@.@..@@.@@@@@@@@@@@.@@..@@.@@@@@..@.@..@@@@@@@.@.@@.@@@@@@@...@@@@@..@@@@@@.@@@.@@
|
||||
..@..@@@@@@@@..@@@.@...@.@@@.@@@....@@@@...@@@@@@.@.@@@.@@@@...@@@@...@@.@@.@.@@@@@@@.@..@.@@@@@.@@@@@@@@@@.@@@@@@.@..@@..@@@@@.@@@@@@.@.@@@
|
||||
..@.@@@@@@..@@@@@.@.@@@..@.@@@@@.@@@.@..@@@@@@@.@@@@.@@@@@@@...@@@@..@.@@.@@@..@.@@@@@@...@@@@@..@..@@.@@@.@@@@@@@@..@@@@@@@@@.@..@.@@@..@.@
|
||||
.@@@.@@@@@@.@@@@.@@@@@@.@.@@@.@.....@@.@@@@.@..@..@.@.@...@...@.@.@@..@@@@@@@.@@.@@.@.@@.@.@@@@@@@.@@@....@@.@@@@@@@.@@@@@@.....@..@@@.@@@.@
|
||||
..@...@@.@@@@..@@@@@@@.@.@.@@@@@@@@..@.@@@.@@@.@@@.@@@@@@@..@@@...@@@.@@@..@.@.@@@@@@...@@@.....@@@@@@@..@@@@@@@@@@@..@@@@@..@@@@.@.@.@@@.@@
|
||||
@.@..@@@.@@@@@@..@.@.@...@@@@@@@..@@@@@@@@@@@@@@..@@.@@.@@...@..@@.@@..@@...@@@...@@@@@@@@@@@@...@@@.@@@@@@@@@...@.@@@....@@@@@@.@@@.@@@@@@@
|
||||
.@@@.@@@@@@.@@.@@..@@@@@@.@.@..@.@@.@@@@.@@@..@.@@@.@@@@.@@@@@..@@..@.....@.@@@@@@....@@@@@@@@..@@@@@..@..@@.@....@.@@@.@..@..@.@@...@@@@.@@
|
||||
@@@.@.@@.@@.@..@.@.@@@@.@.@@...@@.@.@.@@@@@...@@@@.@@.@@@..@@.@@@.@@@.@...@@.@.@@.@@.@@...@@.@@..@@.@.@@@@@@@@.@@...@@@@@@@@@@@.@@..@@@@@@..
|
||||
.@.@.@@..@.@.@@.@@@@@..@@.@@@@.@...@@@.@.@@.@@@.@@@@@@@@..@@..@@@.@@@..@.@@.@.@@@@@.@@@@@@..@@@@@@@@@@@@.@@@@.@@@.@@@.@@@.@@@@..@.@@@@.@@.@.
|
||||
.@@@.@..@.@@..@@@.@@@@.....@@@@@@@@@@.@.@.@@@.@@@@@....@@@.@@@.@@...@@@.@@@..@.@@.@@@@@@.@...@@.@.@@@.@..@@@@@@..@@@@@..@.@.@..@@.@@@@@@@@@@
|
||||
.@.@@@.@.@@@.@.@@.@@.@@..@.@@@.@..@@..@@@@@.@.@..@.@..@..@@.@@@.@@.@@...@@@@@@@.@.@@@.@@...@.@@..@.@.@@@@@@@@@@@@@@@@@@@.@.@@@@@..@..@@@@@@.
|
||||
...@.@.@@.@@@@.@.@@......@.@.@..@@..@@@.@@@@....@@@.@...@.@@.@@@@@@@@@...@@..@.@.@.@@...@@.@@.@...@@.@..@@.@.@....@@..@@.@@@..@@.@.@@@..@@@@
|
||||
@.@@@...@.@@@@.@@.@..@@@@..@@@@@@@@..@@@...@@@@@.@...@@@@@@@@@@...@@@@@@@@@@.@@@@@@@@@...@@.@@..@@.@@..@...@@@@@@@.@@..@.@.@.@.@@@.@.@.@.@@@
|
||||
@@.@@.@@@@....@.@...@...@@@@@@@.@@@@@@@@@@@.@@@...@@@@@@@@@@@@@@@.@@..@.@@@.@@@.@@@@..@.@@@@..@@@@..@.@.@@.@@@@@@@.@@@@@@@@.@.@@@@@@@@@@.@@.
|
||||
@@@@@..@@..@@@@@.@@@.@@@@@.@@@@@@@.@@@@@.@@..@@@.@.@@@@@.@.@@@..@@.@...@@@.@@..@.@.@@@.@.@@@@@@..@@@@.@@@@..@@..@@@.@@@@@.@.@...@@@@.@@...@@
|
||||
@....@@@@@.@.@@@..@.@.@@.@..@.@@.@@@@.@@@...@@.@@@@..@.@.@.@@.@@.@@.@@@.@.@.....@@@@@.@.@@@..@..@.@.@@.....@@@@@....@..@@@@@@@@@@@@.@@.@@@.@
|
||||
@@@@@@...@@@..@.@@.@..@.@@@@.@@@@@.@@@@..@@@@.@@@@@@..@..@@@@@@..@.@@@..@.@@.@@@@.@@.@@..@@@@..@..@.@@.@.@@.@@.@@@.@@@.@@@@@@@@....@@.@@.@@.
|
||||
@@@@@@.@@@.@@@@@@@..@@..@@@.@@@@@@@@@@@@.@@@.@@.@.@@@.@@@.@@@@.@@@@@.@.@.@@@..@@@@@@@@..@@@@@.@@@@@.@@@..@@.@.@@@.@@@@..@@@.........@@@@@@@@
|
||||
@@@..@.@@@@..@@@@@.@.@@@..@@.@..@@..@@..@.@@@.@@@.@.@.@..@@@.@.@@.@@.@...@@.@@@@.@.@.@@..@...@.@.@@@@...@@@....@@@.@@@@.@.@@@@@@.@@@@.@@@@.@
|
||||
@@.@@@@@@@@..@.@.@@@@..@.@@@@@.@@@@@@@@@.@@@@@@.@@@@.@@@@@@.@@@@..@@@...@@@.@@@@.@@.@@..@@@@.@.@.@.@@@@@@...@@@.@...@.@.@.@@@@@@@@@@.@@@@@@@
|
||||
@@@@@.@@..@@.@@.@@@@@@@@.@@@@@...@..@@@@.@@..@.@..@@@..@@.@@@@.@.@@.@.@@@@.@@@@@.@..@@.@@.@@@.@@@@.@@@@..@@@@..@@@@@.@@..@.@@@@@@.@..@@@.@@@
|
||||
@.@@...@..@@@@@@@.@@..@..@.@@.@@..@...@..@.@.@.@.@@@@..@@@.@.@@@.@..@...@.@@@.@@@@..@@.@@@@@.@@..@@@@.@.@@@....@@@@.@..@.@@@.@.@@..@.@@..@@@
|
||||
@@@.@@@..@@@@.@..@@@..@@.@@@@@....@.@@@@...@@@@@@..@.@@@..@@@@@@@.@@.@.@@...@.@@@.@..@@..@.....@@@@..@@.@@@@@.@..@.@@@@@@@@..@@@..@@@.@@..@@
|
||||
.@@@..@.@@.@.@@@@.@@..@.@@@@@@@@.@@.@@@@@@@.@@@...@.@.@@.@.@.@@@@@@@@@..@@@@@..@@...@.@.@@.@@@@@..@@.@..@.......@@@@@....@.@.@@@@.@@..@@@.@.
|
||||
.@..@@.@@@..@@@.@@@@@@.@.@...@@@@@@..@@.@@@@@@@@.@.@@@@@@@@..@@@@.@@..@@@@@@@@.@@@..@@@@.@.@@.@.@@@.@@@..@@@..@.@@.@..@@@.@@@.@.@@...@.@@.@.
|
||||
@@@@.@@@@@.@@@.@.@@@.@.@....@..@.@@@@@.@..@@@@...@.@.@@@@..@@.@@@.@@..@@@..@@@.@...@@.@@@@@.@@@.@.@@@.@...@.@..@.@..@@@@@.@@@@@@@@.@@.@@.@..
|
||||
..@@@..@@@@@@@@@@@@..@@@@.@@@.@@.@@@..@@@.@.@@@@@.@.@@@@.@@@@.@.@@@@@@@@@.@@@.@@..@@@@@..@.@@.@.@@@..@.@.@@..@.@.@@@..@......@@@@.@@@@.@.@@@
|
||||
@@@@.@..@.@...@.@.@@@@@.@@@..@@@@.@@@..@@@@.@...@@..@@@..@.@@.@@@@@@.@@@.@@@@@@...@@.@@@..@.@@.@.@.@@@@.@@.@@@@.@@@@@@.@@@@@@@@@..@@..@.@.@@
|
||||
.@.@@@@..@.@.@@@.@..@@@.@.@@@@.@.@.@@..@.@@@@..@...@@@@@@@@@.@@..@.@@@@@@@@.@@..@.@@@.@.@.@@@.@@@@@.@.@@@@@@..@.@.@.@@@@@@.@@.@@@@@.@@.@.@@@
|
||||
@..@@@@@@@.@@@@@.@.@@@@.@@@..@@.@@@...@..@@@@@.@@.@@@@@..@.@@.@..@@@..@@..@@@@@@@@@.@@@@@..@@@@@@@@@.@..@@.@...@@@.@..@@.@...@@@.@@@.....@@@
|
||||
...@@@@@@@.@.@@@.@.@@.@@@.@@@@@..@@@@@@@@..@..@.@.@@@.@@@@...@.@@..@..@.@@.@...@@.@@.@.@@@@....@..@@@@@@@@...@@.@.@.@@@@@..@@@@@@.@..@@@.@@@
|
||||
.@@@.@.@@....@@@..@@@@@@@..@...@@.@@@@.@@@@@.@@.@..@@@..@@.@@@@@.@..@@@..@@@@@@@.@.@@...@@@..@@@@@@..@@@@..@@.@@..@.@@..@@.@@@@.@@@@@@@@@@@@
|
||||
....@@.@@@.@.@@...@..@.@@@.@...@@@@.@.@@@@@.@@@@...@@..@@.@@@.@..@@....@..@@@@@.@@@.@@@..@.@...@...@.@@@@.@..@@.@.@@@..@.@@@@@@@@@@.@@@@...@
|
||||
.@@@...@.@@@@....@..@@@@@@@@@@@@.@@@.@@@@@@@@@@@...@.@@.@@.@@.@..@@@@.@@@@@@@.@@@..@@@.@@@@@.@@@..@.@@.@.@.@@@@@@.@@@@@@@.@.@..@@@@@.@@.@@..
|
||||
.@@@@@@@.@@..@..@@@@@@@@@.@.@@@@@.@@@@.@@@..@@.@@..@@.@@@@..@@@@@@@.@.@@@@@@.@@.@@@@@@@@@@@@@@.@@.@@@@@@@@@@...@..@@...@@@@..@@.@..@..@@@@@.
|
||||
.@@@@.@@.@@..@@@.@@.@.@@@.@.@.@@....@@@..@@.@@@@@@@@@@.@@@@@.@.@@@...@@@@@@@@....@@.@@@.@....@@@@@.@@@@.@@@..@@...@...@.@@@..@@@.@@@@@@@@@..
|
||||
@.@@@..@@.@@@..@@.@.@.@..@@@@@@@@@@@@..@.@@.@@@@@@@.@@@@@@@@..@.@@.@.@@@..@@@..@.@@@@@@..@@.@@.@@@@.@@@...@@@@...@.@..@@.@@@.@.@@@@@@@.@@@@.
|
||||
..@@@@.@@.@.@.@@@.@@@..@..@@@@@@..@.@@@.@@.@.@@@@@.@@.@@@@@...@.@.@@.@.@@@@@.@@@@@@@@@@@@...@.@.@@@..@.@@@@@@..@.@..@@@.@..@.@.@@@.@.@@@....
|
||||
..@@@.@..@@@.@@@..@@.@.@@@@.@@.@@@@@@@@@@.@@@@.@@.@@@@@.@..@...@@..@@@....@@@.@.@..@@@@@.@..@@..@@.@.@@@@..@@@@@.@.@..@@.@@.@@.@@@@..@@@.@@.
|
||||
@@.@@.@.@@@@@@@@@.@@.@...@@@@@..@@@@.@.@@@@@@@@.@@@.@@.@...@@..@@@@@.@..@@@@.@@@.@..@@@@@..@@@@@.@@@.@@.@@@@.@@@@@@@.@@.@@.@.@..@.@@..@@@@@@
|
||||
@.@@..@.@@.@..@@@@@@@.@@.@@.@@@.@.@.@@@...@.@...@.@...@.@@@@@..@.@@@@@@@.@.@.@@..@.@.@@.....@.@@@@@@@@@@@@@.@@.@.@..@.@...@@@..@@@@.@@@@@...
|
||||
@@@@@@@@@@@@@@.@.@@@@@.@.@@@@@@@@.@@.@.@@@.@@@@@@@..@@@@.@@@@.@@@@.@@.@@@@.@@@@@@@@.@@@@@@@.@@.@.@..@@.@.@@..@..@.@@@.@.@@.@@.@.@.@@.@@@.@@@
|
||||
@..@...@..@@@@@.@.@@@@@@@@@...@@@.@@@.@@.@@@@@@@.@..@@@.@@.@..@@@@.@@.@@@...@@@@@@@.@.@.@@.@@....@@....@.@@.@@@@..@@@@@@..@..@@@.@.@@@@@@.@.
|
||||
@.@.@..@..@@..@@@.@..@@...@@@@@@@.@@.@.@..@..@....@@.@@.@..@@@...@@@@@@.@@@@@@.@@.@.....@@..@.@.@.@@@.@@.@.@@..@@@.@@@@@..@@@..@@.@..@..@@@.
|
||||
@@@@..@.@.@@.@..@@@@@@@..@.@@@.@@.@..@...@@@@@.@.@@@@@..@@.@@@@@@@.@@@@@.....@.@.@..@.@@..@..@@@@@@.@.@..@..@@@@@.@.@@@@.@@@@@..@@.@.@..@.@@
|
||||
@@..@@@@@@@@@@@@@....@..@@@@@@@.@@@@@@.@@@@.@.@@@@@@@@@@@..@@@@..@.@.@..@@@@..@@.@..@.@@@@@....@@@@@...@@@.@@@...@.@.@.@@@.@.@@@.@.@.@@@.@.@
|
||||
@@@@.@.@@@...@..@.@..@@@@@@@@@.@.@@..@.@@@..@@@@@@@.@.@.@@@@.@...@@@@@@@@..@.@....@@.@@..@@...@@.@@.@@@.@.@..@.@@..@..@@.@@..@@@@@@@@@.@@@@@
|
||||
@@.@.@..@@@.@@.@..@.@.@@@@@@@@..@@.@@.@.@@.@.......@.@@...@..@..@.@@.@@@..@@..@..@@@@@@@..@@.@@.@.@@...@@@@@@.@@@@@@.@..@..@@@.@@@.@@.@@@@..
|
||||
@@@...@....@.@.@.@.@.@@....@@@@@.@@@...@@@@@@.@@@..@@.@@..@.@@.@@@@.....@..@@@.@..@.@@.@@.@@@.@@@.@@@@@@.@@@@@@.@..@@@.@@..@@.@@@@@@@@@..@@@
|
||||
@@.@@.@.@@@@@.@@.....@@@.@@@@..@@..@.@...@@@..@@.@@@.@@.@@@.@.@@.@.@..@..@@@@@.@.@@@@.@..@.@@.@@..@.@@@@@@@..@@@..@.@@@...@@@..@@@@@......@.
|
||||
.@@..@@@@@@@.@.@@@@@@@@..@@@@@@@..@.@@@....@@@..@..@@@..@.@.@.@@@@@.....@@.@@@@@..@@@@..@.....@..@@@@.@@@.@@@.@@@@.@@@@.@.@..@.@.@...@@.@.@@
|
||||
@.@@@.@.@@@@....@.@@@..@@..@@.@@@@@.....@@.@@@@@@@..@@@@@.@.@..@@@@@@@....@.@.@@@@@@.@@@@@@@.@@.@.@@@.@@@@@@@@@.@@@@.@@@.@@@.@@.@.@@.@@.@...
|
||||
.@@.@.@@@@@.@@....@@@.@@@@@@.@@@.@.@@..@@@.@.@..@.@...@.@@@..@.@......@@@@@@@@@@@.@.@.@.@@@.@.@@....@@@..@@@.@@@@@@@...@@@@@.@@@@@@.@......@
|
||||
.@@.@@....@..@@@@.@@@.@.@.@.@@.@@@.@@@.@@@.@@...@@.@@@@@.@@@@..@@.@..@@@@@@@@@.@@@@@@@.@..@@@.@.@@...@@@@@@@.@@@@@@@@.@.@@@.@@@@@@.@@@@.@@@@
|
||||
..@@@@.@.@@...@@..@@@...@@.@@@@@@@@@@@.@@@..@@@.@@.....@@...@@@.@@.@..@..@@.@.@@@.@.@@@.@.@@@@@.@@.@@@..@@@@@@@@@@..@.@@@@@@@@.@@.@@@@..@@@.
|
||||
.@@.@@@@@@..@@@@@.@.@@@@@@@.@@@@..@@.@.@@...@@@...@..@@....@@.@.@@@.@.@@@..@@@.@@...@.@.@@..@@..@@.@@@@@@@@@.@@.@@@@@@@@@@..@.@@@.@.@@@.@@@.
|
||||
@.@@.@..@......@@@@@.@@.@@.@@@@@@@@.@.@@.@.@@..@...@...@.@@@.@@@.@@@@@.@..@.@@@@@@@.@@@@@@..@@@@..@@@.@.@@@@..@..@@@@@..@@.@@.@@..@..@@.@@..
|
||||
@@.@@.@@@@@@.....@@@.@.@@.@@@@.@.@@..@.@.@@.@@@.@..@.@@.@@@@.@@@@@..@@..@@@...@.@.@@@@..@@@...@@@.@@@@@.@..@@@@@@@@@..@@.@@@@@.@@@@@@..@@.@.
|
||||
....@@@@.@....@@@@@@@@..@@@@@@.@..@@@@..@.@@@@..@.@@@@@@@@.@@@@@@@@@@.@@@@@@@@@@@.@.@@@.@.@@.@@.@@@@.@...@@.@@@@@@@@.@@.@.@@..@@@.@.@.@.@.@@
|
||||
.@.@.@.@.@@@@@@.@@..@@...@.@@.@@@.@@.@@@.@.@@.@@.@.@@@.@..@@.@......@@@@@...@..@@@@@@@@@.@@@@@@@@@@....@@@@.@...@@@.@@@@.@.@@@@@.@@@...@.@@@
|
||||
@@.@@.@@@@.@@@@.@..@......@@@.@.@...@@.@@@.@@@@@@@@@@@@@..@@@.@.@...@@@@@.@@.@@@@..@.@@@.@.@@.@@@@.@..@.@@@@.@@..@@.@..@@@.@@@@@.@@...@@@.@.
|
||||
.@@@@.@@@.@@@@@@@@@@@@@@.@@@@@@@@..@.@@@@@@@.@@.@@@.@.@@.@@@.@@@@@@.@@@@.@@.@@@@.@.@@.@@@..@@@.@.@@@....@@.@..@@@.@.@@@..@@@@.@@..@.@.@@@@.@
|
||||
@@@..@@@@.@@..@@@@@@@@@..@@.@.@.@@@@@@.@@.@@.@@.@.@@@@@.@@..@.@@@.@.@@@@.@@....@@@@.@...@@.@..@@..@..@@@@@@@@.@.@@@.@@.@..@.@..@.@.@@@...@.@
|
||||
@.@@@..@..@@@.@@@@@@.@@@@@@@.@.@.@.@@@..@.@@@.@@@@..@..@@.@.@@@@@.@.@@.@.@..@@.@@@@@@.@.@.@@.@@@@@@@.@@@..@@...@@@..@@.@@@.@@@@@@..@@.@@.@@@
|
||||
.@@@@@.@@@...@@@@.@..@@@..@@..@.@@@@..@........@@@.@@.@@.@.@@@.@@@@...@@@@@@..@@@.@.@...@@.@@.@@.@@@...@.@@@.@@.@.@@.@..@@..@.@@@@@@@@...@@.
|
||||
@@@...@@@@@@@@@@....@@@@@.@.@.@..@..@.@@...@.@.@..@@@@.@.....@@.@..@..@...@@@@.@@.@@@@@@@.@@.@@.@@@@.@@@@@.@@.@@.@@@@@.@@@...@@@@@.......@..
|
||||
@@@..@..@@@@@...@@@@@@@@.@@.@@@@@.@@.@@.@@@@...@.@@@@@@@@@@@@@@@..@.@@..@@@.@....@@.@@@@@.@@@.@@@@@..@@@@.@@@@.@@.@....@@@@..@@@@@@@@@@.@..@
|
||||
@@.@@@@@@@..@@.@@@@..@@@@.@@@@@.@@.@@.@@@@@@@.@@@@@.@.@...@@@..@.@@..@@@@@..@@@@@.@@@@.@@@@.@.@@.@@@@@@.@@@@.@@.@..@.@@@..@.@@@.@@.@@@@.@.@@
|
||||
..@@..@.@@@@@@.@@.@@@@@@@@@.@..@.@.@@..@.@@@@@@@@@@@@.....@.@..@@@...@@@.@@..@@.@@@.@.@@@@@@.@@@....@@.@@..@@.@@@@@.@@..@@.@@@@@@..@@@.@@..@
|
||||
@@..@.@.@.@@.@@.@@@@@.@..@@...@.@@@..@@..@@@.@@@..@@.@@@@@@@....@.@@@@@@..@@.@@.@@..@.@@@@@@...@@@@.@@@....@@@..@@..@@..@.@@.@....@@.@.@@@@.
|
||||
@...@@.@@@.@.@@@.@.@@@@@@@...@@.@@.@@@..@@@@.@@@.@@@.@.@.@@@@@@.@..@@@@@@@@@@.@@.@.@@.@.@.@@@.@@.@@@..@.@@@.@.@.@@@@..@...@..@@@@.@..@.@.@@.
|
||||
..@@@@...@@@.@@.@.@@@@@@@..@@@.@.@@@@@.@@@@@@@@@.@..@@@@@@.@@@.@...@@.@@@@@@@@.@.@.@..@@@@@..@@@.@.@.@@.@@...@.@@....@@@@@.@@@@.@..@..@@@@.@
|
||||
.@@.@@...@.@.@..@.@@@@.@@@.@.@.@.@@@..@@@.@@@@@@@@@@@.@.@@@@@.@@@.@.@@.@.@.@.@@.@@@@.@@@.@@@@..@@@@@@@@@@@...@@@@@.@@@@...@...@@.@@.@@.@@.@@
|
||||
.@...@@@@.@@@.@@..@@@@@@@.@......@@.@..@@@@@@.@@@@.@@@.@@@@..@@...@.@@@@@@@.@.@@..@@.@..@@.@@@@@@..@@@@@@@@@@@@@@...@.@.@@@@@.@@@.@@.@@@..@@
|
||||
@@.@@.@.@@.@@.@.@@..@@.@@..@...@.@@@@.@@@..@@@@.@@@@@@@@..@@@.@@.@..@@@@.@@@.@..@@@@@@@@@@@..@@@.@...@@..@..@@@@.@@@@@.@@@@@@...@@.@.@.@@.@@
|
||||
@@.@@@.@@@@@@.@.@@@@@@@.@@@@@@@@@..@@.@..@@@@.@..@.@@.@@@.@.@.@.@@@@.@.@.@.@.@@.@.@.@@@@@@@@@@@..@@......@@@.@@.@@@@@@@@@@@..@..@..@@@@@@@@@
|
||||
@@@@.@@.@@@.@.@.@@@@..@@@@@@@@@..@..@.@@@.@@@@@..@@@@@.@@@@@..@@@@.@@.@...@@...@@.@..@..@@@...@..@...@@.@@@.@@.@..@@..@@@@@@@@@@@@.@@@@.@@@.
|
||||
@@ -3,7 +3,7 @@ package grid2d
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"adventofcode2024/utils"
|
||||
"adventofcode2025/utils"
|
||||
)
|
||||
|
||||
type Grid[T any] struct {
|
||||
|
||||
@@ -3,9 +3,9 @@ package inputs
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"adventofcode2024/utils"
|
||||
"adventofcode2024/utils/grid2d"
|
||||
sparsegrid "adventofcode2024/utils/sparseGrid"
|
||||
"adventofcode2025/utils"
|
||||
"adventofcode2025/utils/grid2d"
|
||||
sparsegrid "adventofcode2025/utils/sparseGrid"
|
||||
)
|
||||
|
||||
func ToInts(input string, sep string) []int {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"adventofcode2024/utils"
|
||||
"adventofcode2025/utils"
|
||||
)
|
||||
|
||||
type SparseGrid[T comparable] struct {
|
||||
|
||||
Reference in New Issue
Block a user