feat(sterni/aoc/2022): day13 BQN solution

Change-Id: I401ba09198d447628fa76d811fd4fe780baa8240
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7586
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Autosubmit: sterni <sternenseemann@systemli.org>
This commit is contained in:
sterni 2022-12-13 14:56:07 +01:00 committed by clbot
parent 4f1b55c27b
commit 8fda0544d7
3 changed files with 18 additions and 2 deletions

View file

@ -1,6 +1,6 @@
# needs export BQNLIBS=/path/to/mlochbaum/bqn-libs
Split •Import "/strings.bqn"˜¯11•SH "printenv""BQNLIBS"
ReadDec •Import "../../lib.bqn"
ReadDec,ImportBqnLibs •Import "../../lib.bqn"
Split ImportBqnLibs "strings.bqn"
MakeOp {
𝕊 a"+"b: 𝕊 a+b;
𝕊 a"*"b: 𝕊 a×b;

View file

@ -0,0 +1,14 @@
lib •Import "../../lib.bqn"
str lib.ImportBqnLibs "strings.bqn"
i >"[","]""⟨","⟩"(•BQN str.ReplaceAll)¨¨0((¨¯1˙¨(+`(=)¨)))•FLines "input"
Ord {
i1 𝕊 i2: 11•Type¨ i1i2? ¯110˜i1(=+)i2;
i1 𝕊 l2: 10•Type¨ i1l2? l2 Ord˜ i1;
l1 𝕊 i2: 01•Type¨ l1i2? l1 Ord i2;
l1 𝕊 l2: 00•Type¨ l1l2?
10(/)l1 Ord¨((l1l2)((+1))) l2
}
•Out "day13.1: "•Fmt +´1+/(1=Ord´)˘i
•Out "day13.2: "•Fmt ×´12++´˘¯1=26Ordi

View file

@ -11,3 +11,5 @@ SplitOn ⇐ ((⊢ (-1˙)⍟⊣¨ +`∘(1⊸»<⊢))∘(≡¨)⊔⊢)
SplitAt (())
_fix {𝕩 𝕊 𝔽 𝕩}
ImportBqnLibs {•Import 𝕩˜"/"˜¯11•SH "printenv""BQNLIBS"}