day 15 init
This commit is contained in:
10
2021/day15/EXAMPLE.txt
Normal file
10
2021/day15/EXAMPLE.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
1163751742
|
||||||
|
1381373672
|
||||||
|
2136511328
|
||||||
|
3694931569
|
||||||
|
7463417111
|
||||||
|
1319128137
|
||||||
|
1359912421
|
||||||
|
3125421639
|
||||||
|
1293138521
|
||||||
|
2311944581
|
100
2021/day15/INPUT.txt
Normal file
100
2021/day15/INPUT.txt
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
7173312811251922158911469918987552198919812111716172146671617245481829877994222545642918723611761161
|
||||||
|
4646216972193253589269976231119311134928199248898455211321437231815174172121741121975282198233991494
|
||||||
|
3289492215191791411967453954334211769221445712443155649188599429873192222251651618191431193771913161
|
||||||
|
4515378885673214677819994531796439912658321147432167119218169567397836391632659222129836129869511916
|
||||||
|
2712221811579451126675135153463233218127758873121423588977247994131262217141894124191532919392181221
|
||||||
|
2178721375452418378151119191462965597273934829892424135142928116384159551744519391881971747591122391
|
||||||
|
5989829351931297973698946772289195611999114116457994829931431852246618418421865212115519163272761923
|
||||||
|
6593812111961641351113628479353219414419586755618193231529719388229163911675197467437421311312239179
|
||||||
|
1367332414491292869836537117999611111221111953549366768254717911485954325698192656364326199224393931
|
||||||
|
3823194741411958284195341318764321126955567853592981221895781591822131731123421219346319199699661811
|
||||||
|
2768392277233761123433164969394413212112469222229798171712192846251349511611257231733341931718783244
|
||||||
|
6211686449674219169788158851614122686169727933982119884512121119558991113337122163499339173141629831
|
||||||
|
8964588262473118893646161133718696168932118613823336981243112241379921491861914992225224246756182418
|
||||||
|
2163359261942752538197461382831351939177272236845211918187697144693874631793929811184394969994511798
|
||||||
|
7989114898193161218935379299733232825223621812115731415952869113232982123295392574119379211945415319
|
||||||
|
2981541411882383967359943494764147677122681664351614692114199243764398471277125818246414966145121199
|
||||||
|
5137573281125648957552155112919221115194983216967212771366843828993746973731199925338771326696133114
|
||||||
|
3766559511919239237173557181961523331983888219226659121522293237112764226926452246137293192651819113
|
||||||
|
3682758681999816113831312836469969232193734111621424211857181274988592869111461771921513621211243412
|
||||||
|
1948613863321211959111219591667512152147132817872211112132781958772886144935937148416627115359861937
|
||||||
|
5344911181727365389869235886885188325146145531191367511892525913156626271219699181915745829815424589
|
||||||
|
1921768161912919191122421721152779172441236981211235365113916763299169389182841162652365191929621634
|
||||||
|
7426456282867924726354983131829724281948296112363261845399134721793117999834413631475537141926412639
|
||||||
|
9239218892837834121193535318983411257861171711911122649161941873915268198422451274213142821191181149
|
||||||
|
2142233113938879859911716118232136567249199181221211458588429128553241944195818216437253326115516261
|
||||||
|
4263229279237581194769911939818975846746332753192816433171243142193222961892988199519393411318675131
|
||||||
|
5931431844789494579714797652192131161119133814229515928519858118391991289576164912398122913213397599
|
||||||
|
2721961279391263971273951243381713261657382114473995987479128836442222129299433186828222392379946598
|
||||||
|
5721194922655214111113638224216129848113795111212977322119719244642824136299146894543411699272447653
|
||||||
|
1721283151419121619299916438767182692133635934419762683731479187219469718126125942443152124252117214
|
||||||
|
1191318114125371538282471992772631716712152159418533811911319228328921272115954283291193338159541897
|
||||||
|
1992998717991939712294189151345342119816611271962276482851232831211636198338141352118191443674663948
|
||||||
|
1161696145282521595951182122631527918224737193572179344636436218858337162961132231795163829188381192
|
||||||
|
6941211141653838595642461762596975428188729157141581868193713799899662916781294793123132681958118616
|
||||||
|
1819477158632417189919213535853313238553111151416298436598333519285362224819522881471912121385128664
|
||||||
|
4131994851618912997621891835224828464921118721544139921463917432371971621819421564868949338392959375
|
||||||
|
3133242592422467724638515112598929161738561343962999211758244193964415258861531512181917956372914815
|
||||||
|
2851732889555112914338252135996931333699122198624171123479362627153221311234119682211133193122826311
|
||||||
|
8572333787948173113891239811786852446329671165322978635241133123367111997212895127886592793919272615
|
||||||
|
4491459926325229881291911822161139341194221969828485936191892191452693598169844422764559177311791991
|
||||||
|
7711224386721991421971479559514658827234215923612982938336455918196228323274887266866828172793318129
|
||||||
|
1792133811393571193248372723564225172181126791174377121318932411884213621147116123831958827815214339
|
||||||
|
2155469978392417716111522211533192455439119614121568579123143651567222761914274317316466323996119924
|
||||||
|
8623177814111391292499597672365634732111139269561125392732981323319126423198138385128561991559391782
|
||||||
|
1842517821951178317281681455259131499922139421927127818952311122613122361391261889385551741415311174
|
||||||
|
1121489791429687666926699327995141292912715883217747843259918621498111261621125443139314125515579392
|
||||||
|
4926852919113151918334999277973512249327141773526658912259778215269924712911844817319595442111992296
|
||||||
|
4121922141952419619152691739416242743191911121434241927499148486191311291548232399983325412914177521
|
||||||
|
2729193162333518598231521726292747161811711199291367239129432321128819725987611419151129841314223329
|
||||||
|
5161319319642221756114718511892119842126129917614211814292897914584213663525125888918911841344441167
|
||||||
|
1218919131819647671213811726979395328283925417535819381416121438921296118284911421324239118621797149
|
||||||
|
1296189848121155113349984582165659294526124822124196245979513919841416218999219691561172279151111152
|
||||||
|
8131333157919249442912528253243598392791124337511444713511932179243517538421849512824282112125754398
|
||||||
|
1889681196198926571218233416129912265342816929472192326228618815919519181119971199965864884926329684
|
||||||
|
4494347982618719134522341621218316919443481761161413736159296282296287392981826492616258178597149171
|
||||||
|
3372889451184198132111171777814111179543243756738721486438829911265492817181811258219678819715934783
|
||||||
|
2616818924444129774824882961271546911121478523975641935416133917974684665993259291354189455115256112
|
||||||
|
2811839229428511712146911429195623518752949851188111438115675381894374219416116769619292646212281281
|
||||||
|
1119763626283549911491359216384192428413381423111124499192126173788341749798821599693991125531415822
|
||||||
|
2349891181211194888159436111111772211361273821434343227381149832784862518216691117651763161816911119
|
||||||
|
8418725583117989441352169137523561277849413638828989992112444397932486713918531213173217496612196229
|
||||||
|
8194221916977995111288941528855138698421192518849711165396995252187534931798892359817432158363564921
|
||||||
|
4868199762329594579418795281999591295951216119125346219151394998351623911582981973134399941972155729
|
||||||
|
2472125294499111714693695173281491912974791153411681134725132321246194826113275721861259118519171112
|
||||||
|
1633713781533969985751914138835182737446812176394116926162181989316432892346283723213927824377271732
|
||||||
|
7727749711573911939746322419297737232517397289293189731312622299196183811592993841253139241811194299
|
||||||
|
3444125976332938779126885711113586551233924262213299924415281989123291391581652215852716859551746751
|
||||||
|
1719317631143843451943995721353922513913657532736116317191133165811217264495991377397112229124311117
|
||||||
|
5861535147284127128962317613425858155751422182951141984197973311438338913558511976717312956251819479
|
||||||
|
9299184959412999345164229713288931729114929419973869591951391199698548124823539329547718426332534959
|
||||||
|
9851246238111471391482375191872321911276443744269832118973631471681521191762795722912611411731819333
|
||||||
|
9869224453198466342944911731614713469959619233517151937535427336961129724161969599182912551574172352
|
||||||
|
6371551729394919281768279284119868777896992246419593152391148181591759131189212591171199419129198313
|
||||||
|
2295927349268467493318173971873622191313441346343628139715519647853238244192929217593451153811319811
|
||||||
|
1211231819479781274911189539311996147632231799793892194619218459139118323385691136152122391381938288
|
||||||
|
9492197194223986366157191556366723812164435115416454484879391237714149926888136741911511279936168912
|
||||||
|
2111411993964171277723732569599285124872178711536341321575124391377998587214881369916299311339162115
|
||||||
|
1857186715221591921589199519221499976826598488872332119919989134621681411613762118296121212833167613
|
||||||
|
9718337129818367133629146122228911964852312941892555957139253694142728519112114864536965987514966211
|
||||||
|
2415331399185119912149918119982246814444727537971643769252248161761394618613421452811825842399129131
|
||||||
|
2637271813357222157145794211314329984964767141817213542216811653152351899121891897921939593213111314
|
||||||
|
1342912217283425272931147739959428495933619188311493691141954225917482937193916388217813352129619863
|
||||||
|
6171111767238611133869357659223281188142241123851329951559176773195191456535911253118971695714976355
|
||||||
|
1585271618186833837341918341979188526816145718783214959195393118172461327399931821617411511911199863
|
||||||
|
6461447221181217136723211129799371134424983996611256271122958541942582422342539318328941531711964915
|
||||||
|
1634222839756824796924611186112289121315141467251822858181833282112958592898298119557131913669565746
|
||||||
|
8413516892412482311827331191357514129984673942271927712113191241311815321828498499757481515425571313
|
||||||
|
9292913153714142122372452413224612721993331697395348762817819282291954241689949412128759187143413229
|
||||||
|
8114111293919599241719615591117821715267715772911268593138158693924671111148633916249731251464216222
|
||||||
|
1611972412142482865862148181257292295187211989739221122114612118449211946324743944111224717432567371
|
||||||
|
4426979492592797511999213492912687199638947476153533611299113561131993655419139311131141486691318421
|
||||||
|
4819559316111356226292342978981271723115518319562529917291119531537967212778289141272129186123618729
|
||||||
|
1322122459351831389234143421535699946127862425916492541436671171929936117393814918199114528361615475
|
||||||
|
1832241129859195291112852541592681571461425225854732933536919122531988823161646159389214184462152416
|
||||||
|
3537959443491836554998141843397447943981721116171172126461321895151415435116233545219833813151222693
|
||||||
|
1611963219749418211652174418113582118994319912999813714577885544917887217951819321971873298986543979
|
||||||
|
2483836259212216629932122153213826317397734611722254411988417882585921553111163857875961521399991758
|
||||||
|
7519842459152519311265791212932251261948342231857165828993185221622421253711999122289324849113714118
|
||||||
|
2278835219311786262197322199149957832597951398143478923177181437824396993412962115952333951727514718
|
||||||
|
1812819933161952113937239491658431421595957151868228264138181469731616171293123193688276811119911925
|
58
2021/day15/Makefile
Normal file
58
2021/day15/Makefile
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
# AOC daily Makefile - GNU make only.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 Bruno Raoult ("br")
|
||||||
|
# Licensed under the GNU General Public License v3.0 or later.
|
||||||
|
# Some rights reserved. See COPYING.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along with this
|
||||||
|
# program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.html>.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
|
||||||
|
#
|
||||||
|
|
||||||
|
INPUT := INPUT.txt
|
||||||
|
SHELL := /bin/bash
|
||||||
|
|
||||||
|
CC := gcc
|
||||||
|
|
||||||
|
LIB := aoc_$(shell uname -m)
|
||||||
|
INCDIR := ../include
|
||||||
|
LIBDIR := ../lib
|
||||||
|
LDFLAGS := -L$(LIBDIR)
|
||||||
|
LDLIB := -l$(LIB)
|
||||||
|
|
||||||
|
export LD_LIBRARY_PATH = $(LIBDIR)
|
||||||
|
|
||||||
|
CFLAGS += -std=gnu99
|
||||||
|
CFLAGS += -O2
|
||||||
|
CFLAGS += -g
|
||||||
|
CFLAGS += -Wall
|
||||||
|
CFLAGS += -Wextra
|
||||||
|
CFLAGS += -march=native
|
||||||
|
CFLAGS += -Wmissing-declarations
|
||||||
|
CFLAGS += -Wno-unused-result
|
||||||
|
|
||||||
|
CFLAGS += -DDEBUG_DEBUG # activate general debug (debug.c)
|
||||||
|
CFLAGS += -DDEBUG_POOL # memory pools management
|
||||||
|
|
||||||
|
TIME := \time -f "\ttime: %E real, %U user, %S sys\n\tcontext-switch:\t%c+%w, page-faults: %F+%R\n"
|
||||||
|
export PATH := .:$(PATH)
|
||||||
|
|
||||||
|
.PHONY: clean all compile ex1 ex2
|
||||||
|
|
||||||
|
all: ex1 ex2
|
||||||
|
|
||||||
|
compile: aoc-c
|
||||||
|
|
||||||
|
ex1: aoc-c
|
||||||
|
@$(TIME) aoc-c -p 1 < $(INPUT)
|
||||||
|
|
||||||
|
ex2: aoc-c
|
||||||
|
@$(TIME) aoc-c -p 2 < $(INPUT)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@rm -f aoc-c core*
|
||||||
|
|
||||||
|
.c:
|
||||||
|
@echo compiling $<
|
||||||
|
@$(CC) $(CFLAGS) $(LDFLAGS) -I $(INCDIR) $< $(LDLIB) -o $@
|
35
2021/day15/README.txt
Normal file
35
2021/day15/README.txt
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
--- Day 15: Chiton ---
|
||||||
|
|
||||||
|
You've almost reached the exit of the cave, but the walls are getting closer together. Your submarine can barely still fit, though; the main problem is that the walls of the cave are covered in chitons, and it would be best not to bump any of them.
|
||||||
|
|
||||||
|
The cavern is large, but has a very low ceiling, restricting your motion to two dimensions. The shape of the cavern resembles a square; a quick scan of chiton density produces a map of risk level throughout the cave (your puzzle input). For example:
|
||||||
|
|
||||||
|
1163751742
|
||||||
|
1381373672
|
||||||
|
2136511328
|
||||||
|
3694931569
|
||||||
|
7463417111
|
||||||
|
1319128137
|
||||||
|
1359912421
|
||||||
|
3125421639
|
||||||
|
1293138521
|
||||||
|
2311944581
|
||||||
|
|
||||||
|
You start in the top left position, your destination is the bottom right position, and you cannot move diagonally. The number at each position is its risk level; to determine the total risk of an entire path, add up the risk levels of each position you enter (that is, don't count the risk level of your starting position unless you enter it; leaving it adds no risk to your total).
|
||||||
|
|
||||||
|
Your goal is to find a path with the lowest total risk. In this example, a path with the lowest total risk is highlighted here:
|
||||||
|
|
||||||
|
1163751742
|
||||||
|
1381373672
|
||||||
|
2136511328
|
||||||
|
3694931569
|
||||||
|
7463417111
|
||||||
|
1319128137
|
||||||
|
1359912421
|
||||||
|
3125421639
|
||||||
|
1293138521
|
||||||
|
2311944581
|
||||||
|
|
||||||
|
The total risk of this path is 40 (the starting position is never entered, so its risk is not counted).
|
||||||
|
|
||||||
|
What is the lowest total risk of any path from the top left to the bottom right?
|
Reference in New Issue
Block a user