about summary refs log tree commit diff
path: root/users/sterni/exercises/aoc/2022
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2022-12-18T15·56+0100
committerclbot <clbot@tvl.fyi>2022-12-20T19·01+0000
commitba719f8f5e8a1bb55a9f4fc99cd0e853f7ec62b8 (patch)
treef7b7388c2a5b87cf9351ed6a508a1f34fd9ece04 /users/sterni/exercises/aoc/2022
parentc9a44bfe1575691eaec449f2e6d0424de0dbcb8a (diff)
feat(sterni/aoc/2022): day18 BQN solution r/5430
Change-Id: I1504cd5e443ff0b28c2d97ae357e5d92c88bba4d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7601
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Autosubmit: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'users/sterni/exercises/aoc/2022')
-rw-r--r--users/sterni/exercises/aoc/2022/18/18.bqn14
1 files changed, 14 insertions, 0 deletions
diff --git a/users/sterni/exercises/aoc/2022/18/18.bqn b/users/sterni/exercises/aoc/2022/18/18.bqn
new file mode 100644
index 000000000000..76ec569fed41
--- /dev/null
+++ b/users/sterni/exercises/aoc/2022/18/18.bqn
@@ -0,0 +1,14 @@
+lib ← •Import "../../lib.bqn"
+
+i ← (lib.ReadDec¨(<',')⊸lib.SplitOn)¨ •FLines "input"
+dim ← 1+⌈´i
+cubes ← i∊˜↕dim
+
+views ← ⟨0‿1‿2, 1‿2‿0, 2‿0‿1⟩
+Exposed ← {(6×+´⥊𝕩)-2×+´views{+´⥊(∧˝˘)2↕𝕨⍉𝕩}¨<𝕩}
+Interior ← {(¬𝕩)∧´views{((lib.Xor`∘((∊∧⊢)∨»∘(∊⌾⌽∧⊢)))⎉1)⌾(𝕨⊸⍉)𝕩}¨<𝕩}
+Displace ← {⌈´(⥊⊢‿⌽⋈⌜views){F‿a 𝕊 𝕩:((-∘¬∘(»((0⊸=⊣)∧>)⊢)⌈⊢)⎉1)⌾(F a⊸⍉)𝕩}¨<𝕩}
+Exterior ← (⊢-○Exposed ¯1⊸=∘(Displace lib._fix)∘(-∘Interior+⊢))
+
+•Out "day18.1: "∾•Fmt Exposed cubes
+•Out "day18.2: "∾•Fmt Exterior cubes