From 3988cfcfc70e49873ddd34a8c8114b511120ebad Mon Sep 17 00:00:00 2001 From: rhiannon morris Date: Sat, 3 Dec 2022 11:24:23 +0100 Subject: [PATCH] answers in bqn, also i broke day1 at some point --- aoc.bqn | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aoc.bqn b/aoc.bqn index 2f9325f..fe5d978 100644 --- a/aoc.bqn +++ b/aoc.bqn @@ -2,17 +2,19 @@ Sub ⇐ {a‿b𝕊𝕩:b↑a↓𝕩} # e Split xs: split xs on occurrences of e (default 0) -Split ⇐ {(⊏ ∾ 1⊸↓¨∘(1⊸↓)) Sub⟜𝕩¨ (» ⋈¨ ⊢-») /𝕨=𝕩∾(𝕨⊣⟜0↩)} +Split ⇐ {(⊏ ∾ 1⊸↓¨∘(1⊸↓)) Sub⟜𝕩¨ (» ⋈¨ ⊢-») /w=𝕩∾(w←𝕨⊣0)} # n Chunk xs: split into chunks of length n (the last one might be smaller) Chunk ⇐ {(⌊𝕨÷˜↕≠𝕩)⊔𝕩} Day1 ⇐ (⊑ ⋈ (+´3⊸↑))∘(∨+´¨)∘Split∘(•BQN⎊0¨)∘•FLines +# ⟨ 72602 207410 ⟩ Day2 ⇐ { B ← ⊣ (A ← {1+𝕩+3×3|1+𝕩-𝕨}) {3|𝕨+𝕩-1} +´˘⍉ (A≍B)´∘{a‿s‿b:⟨a-'A',b-'X'⟩}˘ >•FLines 𝕩 } +# ⟨ 17189 13490 ⟩ Day3 ⇐ { Prio ← ⊢ - ⊑⟜"`&"∘(≤⟜'Z') @@ -20,4 +22,4 @@ Day3 ⇐ { B ← +´∘∾ {a‿b‿c:(Prio¨a)×b∧○(a⊸∊)c}¨∘(3⊸Chunk)∘(⍷¨) (A⋈B) •FLines 𝕩 } -# •Show Day3 ⊑•args +# ⟨ 7683 2488 ⟩