diff options
author | sterni <sternenseemann@systemli.org> | 2021-12-24T14·34+0100 |
---|---|---|
committer | sterni <sternenseemann@systemli.org> | 2021-12-25T10·46+0000 |
commit | 4fbb2a16581535412d7b9fde356eb97f7ce62118 (patch) | |
tree | eebfe9a5158a1a185b79073665f4a2fb1c0449f0 /users/sterni/exercises/aoc/2021 | |
parent | 536f7c134a96b18a4771e33f9a1ba695f8fced5e (diff) |
feat(sterni/aoc/2021): day 6 solution r/3389
Change-Id: Icd21b0f0c92b596fbb369d6f08715a6554259572 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4558 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'users/sterni/exercises/aoc/2021')
-rwxr-xr-x | users/sterni/exercises/aoc/2021/solutions.bqn | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/users/sterni/exercises/aoc/2021/solutions.bqn b/users/sterni/exercises/aoc/2021/solutions.bqn index 83949daa118b..4b6eef823262 100755 --- a/users/sterni/exercises/aoc/2021/solutions.bqn +++ b/users/sterni/exercises/aoc/2021/solutions.bqn @@ -125,21 +125,36 @@ 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 |