From 798b439c4bec6f03f17c86e4d689aad69b79a7cc Mon Sep 17 00:00:00 2001 From: sterni Date: Sun, 26 Dec 2021 00:18:32 +0100 Subject: feat(sterni/aoc/25): day 25 part 1 solution Change-Id: I8ffefd2b85e595bdae2cfb2bf7b34ea63b82c457 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4627 Reviewed-by: sterni Autosubmit: sterni Tested-by: BuildkiteCI --- users/sterni/exercises/aoc/2021/solutions.bqn | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'users/sterni/exercises') diff --git a/users/sterni/exercises/aoc/2021/solutions.bqn b/users/sterni/exercises/aoc/2021/solutions.bqn index ea611e666f31..e5a89182d8f4 100755 --- a/users/sterni/exercises/aoc/2021/solutions.bqn +++ b/users/sterni/exercises/aoc/2021/solutions.bqn @@ -357,3 +357,23 @@ _EnhancedPixelCount ← {+´⥊⊑ (𝕨⊸Enhance)⍟𝕗 𝕩} •Out "Day 20.1: "∾•Fmt day20Algo 2 _EnhancedPixelCount day20Pic •Out "Day 20.2: "∾•Fmt day20algo 50 _EnhancedPixelCount day20Pic + +# +# 2021-12-25 +# + +day25Input ← ".>v" ⊐ > ReadInput 25 +day25ExampleInput ← ".>v"⊐∘‿10⥊"v...>>.vv>.vv>>.vv..>>.>v>...v>>v>>.>.v.v>v.vv.v..>.>>..v....vv..>.>v.v.v..>>v.v....v..v.>" + +Xor ← (¬⊸∧∨∧⟜¬) +MoveHerd ← {(𝕩∧𝕩≠𝕨)+𝕨× (𝕨=𝕩) (Xor⟜(1⊸⌽)∨⊢) (0=𝕩)∧(-1)⌽𝕨=𝕩} + +_fixCount ← { + 1 𝕊 𝕩; + 𝕩 ≡◶⟨(𝕨+1)⊸𝕊, 𝕨˙⟩ 𝔽 𝕩 +} + +MoveAllHerds ← (2⊸MoveHerd)∘(1⊸MoveHerd˘) + +! 58 = MoveAllHerds _fixCount day25ExampleInput +•Out "Day 25.1: "∾•Fmt MoveAllHerds _fixCount day25Input -- cgit 1.4.1