feat(sterni/aoc/2021): day 6 solution
Change-Id: Icd21b0f0c92b596fbb369d6f08715a6554259572 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4558 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
536f7c134a
commit
4fbb2a1658
1 changed files with 21 additions and 6 deletions
|
@ -124,22 +124,37 @@ CO2ScrubberRating ← DebinList 0 >_lifeSupportRating ⊢
|
|||
|
||||
•Out "Day 3.2: "∾•Fmt (OxygenGeneratorRating×CO2ScrubberRating) day3Input
|
||||
|
||||
#
|
||||
# 2021-12-06
|
||||
#
|
||||
|
||||
day6ExampleInput ← ⟨3,4,3,1,2⟩
|
||||
day6Input ← ReadDec¨ ',' SplitOn ⊑ReadInput 6
|
||||
|
||||
LanternfishPopulation ← {+´ (1⊸⌽+(⊑×((6⊸=)∘↕∘≠)))⍟𝕨 9↑≠¨⊔ 𝕩}
|
||||
|
||||
! 26 = 18 LanternfishPopulation day6ExampleInput
|
||||
! 5934 = 80 LanternfishPopulation day6ExampleInput
|
||||
|
||||
•Out "Day 6.1: "∾•Fmt 80 LanternfishPopulation day6Input
|
||||
•Out "Day 6.2: "∾•Fmt 256 LanternfishPopulation day6Input
|
||||
|
||||
#
|
||||
# 2021-12-07
|
||||
#
|
||||
|
||||
# part 1
|
||||
|
||||
day6ExampleInput ← ⟨16,1,2,0,4,2,7,1,2,14⟩
|
||||
day6Input ← ReadDec¨ ',' SplitOn ⊑ReadInput 6
|
||||
day7ExampleInput ← ⟨16,1,2,0,4,2,7,1,2,14⟩
|
||||
day7Input ← ReadDec¨ ',' SplitOn ⊑ReadInput 7
|
||||
|
||||
PossiblePositions ← (⌊´+⟜(↕1⊸+)⌈´)
|
||||
FuelConsumption ← +˝∘|∘(-⌜)
|
||||
_lowestFuelPossible ← {⌊´∘(𝔽⟜PossiblePositions)˜ 𝕩}
|
||||
|
||||
! 37 = FuelConsumption _lowestFuelPossible day6ExampleInput
|
||||
! 37 = FuelConsumption _lowestFuelPossible day7ExampleInput
|
||||
|
||||
•Out "Day 7.1: "∾•Fmt FuelConsumption _lowestFuelPossible day6Input
|
||||
•Out "Day 7.1: "∾•Fmt FuelConsumption _lowestFuelPossible day7Input
|
||||
|
||||
# part 2
|
||||
|
||||
|
@ -147,9 +162,9 @@ TriNum ← 1⊸+×÷⟜2
|
|||
|
||||
FuelConsumption2 ← +˝∘(TriNum¨)∘|∘(-⌜)
|
||||
|
||||
! 168 = FuelConsumption2 _lowestFuelPossible day6ExampleInput
|
||||
! 168 = FuelConsumption2 _lowestFuelPossible day7ExampleInput
|
||||
|
||||
•Out "Day 7.2: "∾•Fmt FuelConsumption2 _lowestFuelPossible day6Input
|
||||
•Out "Day 7.2: "∾•Fmt FuelConsumption2 _lowestFuelPossible day7Input
|
||||
|
||||
#
|
||||
# 2021-12-09
|
||||
|
|
Loading…
Reference in a new issue