feat(sterni/aoc/2021): day 9 solution

Change-Id: I90e7a47d5418abeff1ae7cc5757b6a8b3b0d1086
This commit is contained in:
sterni 2021-12-09 16:51:02 +01:00
parent 343b811bbc
commit 464bbcb15c

View file

@ -13,6 +13,8 @@ ReadInput ← {•file.Lines ∾ •path‿"/input/day"‿(•Fmt 𝕩)}
SplitOn (( (-1˙)¨ +`)=) SplitOn (( (-1˙)¨ +`)=)
_fix {𝕩 𝕊 𝔽 𝕩}
# #
# 2021-12-01 # 2021-12-01
# #
@ -148,3 +150,39 @@ FuelConsumption2 ← +˝∘(TriNum¨)∘|∘(-⌜)
! 168 = FuelConsumption2 _lowestFuelPossible day6ExampleData ! 168 = FuelConsumption2 _lowestFuelPossible day6ExampleData
•Out "Day 7.2: "•Fmt FuelConsumption2 _lowestFuelPossible day6Input •Out "Day 7.2: "•Fmt FuelConsumption2 _lowestFuelPossible day6Input
#
# 2021-12-09
#
# part 1
ParseHeightMap ((()))-'0'
day9ExampleData ParseHeightMap
"2199943210",
"3987894921",
"9856789892",
"8767896789",
"9899965678"
day9Input ParseHeightMap ReadInput 9
Rotate () # counter clockwise
LowPoints {´𝕩(<((-) Rotate »˘Rotate˜))¨ 4}
RiskLevelSum (+´)(1+×LowPoints)
! 15 = RiskLevelSum day9ExampleData
•Out "Day 9.1: "•Fmt RiskLevelSum day9Input
# part 2
NumberBasins ((1+)×)LowPoints
Basins {𝕩((<9)(«»«˘»˘)) _fix NumberBasins 𝕩}
LargestBasinsProduct {×´ 3 1 ¨ Basins 𝕩}
! 1134 = LargestBasinsProduct day9ExampleData
•Out "Day 9.2: "•Fmt LargestBasinsProduct day9Input