diff options
Diffstat (limited to 'users/sterni/exercises')
-rwxr-xr-x | users/sterni/exercises/aoc/2021/solutions.bqn | 3 | ||||
-rw-r--r-- | users/sterni/exercises/aoc/2022/18/18.bqn | 14 | ||||
-rw-r--r-- | users/sterni/exercises/aoc/lib.bqn | 2 |
3 files changed, 18 insertions, 1 deletions
diff --git a/users/sterni/exercises/aoc/2021/solutions.bqn b/users/sterni/exercises/aoc/2021/solutions.bqn index f7247cadf280..755c9440460a 100755 --- a/users/sterni/exercises/aoc/2021/solutions.bqn +++ b/users/sterni/exercises/aoc/2021/solutions.bqn @@ -1,5 +1,7 @@ #!/usr/bin/env BQN +⟨Xor⟩ ← •Import "../lib.bqn" + # # Utilities # @@ -469,7 +471,6 @@ _EnhancedPixelCount ← {+´⥊⊑ (𝕨⊸Enhance)⍟𝕗 𝕩} 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 ← { 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 diff --git a/users/sterni/exercises/aoc/lib.bqn b/users/sterni/exercises/aoc/lib.bqn index 8554d1ee6943..37c518d1fd61 100644 --- a/users/sterni/exercises/aoc/lib.bqn +++ b/users/sterni/exercises/aoc/lib.bqn @@ -13,3 +13,5 @@ SplitAt ← ((⊣≤↕∘≠∘⊢)⊔⊢) _fix ⇐ {𝕩 𝕊∘⊢⍟≢ 𝔽 𝕩} ImportBqnLibs ⇐ {•Import 𝕩∾˜"/"∾˜¯1↓1⊑•SH "printenv"‿"BQNLIBS"} + +Xor ⇐ (¬⊸∧∨∧⟜¬) |