about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2021-12-25T23·18+0100
committerclbot <clbot@tvl.fyi>2021-12-25T23·21+0000
commit798b439c4bec6f03f17c86e4d689aad69b79a7cc (patch)
tree8ab6b9cdd49d2a1a94dba9a0e85b26ddc74c3c05
parentb12dbaa3b6973bdc752e7ce6fa6f1d359a938a96 (diff)
feat(sterni/aoc/25): day 25 part 1 solution r/3409
Change-Id: I8ffefd2b85e595bdae2cfb2bf7b34ea63b82c457
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4627
Reviewed-by: sterni <sternenseemann@systemli.org>
Autosubmit: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
-rwxr-xr-xusers/sterni/exercises/aoc/2021/solutions.bqn20
1 files changed, 20 insertions, 0 deletions
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