diff options
Diffstat (limited to 'users/sterni/exercises/aoc')
-rw-r--r-- | users/sterni/exercises/aoc/2022/11/11.bqn | 4 | ||||
-rw-r--r-- | users/sterni/exercises/aoc/2022/13/13.bqn | 14 | ||||
-rw-r--r-- | users/sterni/exercises/aoc/lib.bqn | 2 |
3 files changed, 18 insertions, 2 deletions
diff --git a/users/sterni/exercises/aoc/2022/11/11.bqn b/users/sterni/exercises/aoc/2022/11/11.bqn index 926fa951df56..12b9b5097a59 100644 --- a/users/sterni/exercises/aoc/2022/11/11.bqn +++ b/users/sterni/exercises/aoc/2022/11/11.bqn @@ -1,6 +1,6 @@ # needs export BQNLIBS=/path/to/mlochbaum/bqn-libs -⟨Split⟩ ← •Import "/strings.bqn"∾˜¯1↓1⊑•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; diff --git a/users/sterni/exercises/aoc/2022/13/13.bqn b/users/sterni/exercises/aoc/2022/13/13.bqn new file mode 100644 index 000000000000..0242cc5093a1 --- /dev/null +++ b/users/sterni/exercises/aoc/2022/13/13.bqn @@ -0,0 +1,14 @@ +lib ← •Import "../../lib.bqn" +str ← lib.ImportBqnLibs "strings.bqn" +i ← >⟨"[","]"⟩‿⟨"⟨","⟩"⟩⊸(•BQN str.ReplaceAll)¨¨0((⟨⟩⊸≡¨¯1˙⍟⊣¨(+`(=⟜≠)¨))⊔⊢)•FLines "input" + +Ord ← { + i1 𝕊 i2: 1‿1≡•Type¨ i1‿i2? ¯1‿1‿0⊑˜i1(=+≤)i2; + i1 𝕊 l2: 1‿0≡•Type¨ i1‿l2? l2 Ord˜ ⋈i1; + l1 𝕊 i2: 0‿1≡•Type¨ l1‿i2? l1 Ord ⋈i2; + l1 𝕊 l2: 0‿0≡•Type¨ l1‿l2? + ⊑1↑0(≠/⊢)l1 Ord¨○((l1⌈○≠l2)⊸(↑⌾(+⟜1))) l2 +} + +•Out "day13.1: "∾•Fmt +´1+/(1⊸=Ord´)˘i +•Out "day13.2: "∾•Fmt ×´1‿2++´˘¯1=⟨⟨2⟩⟩‿⟨⟨6⟩⟩Ord⌜⥊i diff --git a/users/sterni/exercises/aoc/lib.bqn b/users/sterni/exercises/aoc/lib.bqn index 172343b41979..8554d1ee6943 100644 --- a/users/sterni/exercises/aoc/lib.bqn +++ b/users/sterni/exercises/aoc/lib.bqn @@ -11,3 +11,5 @@ SplitOn ⇐ ((⊢ (-1˙)⍟⊣¨ +`∘(1⊸»<⊢))∘(≡¨)⊔⊢) SplitAt ← ((⊣≤↕∘≠∘⊢)⊔⊢) _fix ⇐ {𝕩 𝕊∘⊢⍟≢ 𝔽 𝕩} + +ImportBqnLibs ⇐ {•Import 𝕩∾˜"/"∾˜¯1↓1⊑•SH "printenv"‿"BQNLIBS"} |