bqn poking
This commit is contained in:
parent
26b649080e
commit
39c89ada3d
1 changed files with 4 additions and 4 deletions
8
aoc.bqn
8
aoc.bqn
|
@ -2,12 +2,12 @@
|
||||||
Sub ⇐ {a‿b𝕊𝕩:b↑a↓𝕩}
|
Sub ⇐ {a‿b𝕊𝕩:b↑a↓𝕩}
|
||||||
|
|
||||||
# e Split xs: split xs on occurrences of e (default 0)
|
# e Split xs: split xs on occurrences of e (default 0)
|
||||||
Split ⇐ {(⊏ ∾ 1⊸↓¨∘(1⊸↓)) Sub⟜𝕩¨ (» ⋈¨ ⊢-») /w=𝕩∾(w←𝕨⊣0)}
|
Split ⇐ {(⊏ ∾ 1⊸↓¨∘(1⊸↓)) Sub⟜𝕩¨ (» ⋈¨ ⊢-») /w⊸≡¨𝕩∾w←𝕨⊣0}
|
||||||
|
|
||||||
# n Chunk xs: split into chunks of length n (the last one might be smaller)
|
# n Chunk xs: split into chunks of length n (the last one might be smaller)
|
||||||
Chunk ⇐ {(⌊𝕨÷˜↕≠𝕩)⊔𝕩}
|
Chunk ⇐ {(⌊𝕨÷˜↕≠𝕩)⊔𝕩}
|
||||||
|
|
||||||
Day1 ⇐ (⊑ ⋈ (+´3⊸↑))∘(∨+´¨)∘Split∘(•BQN⎊0¨)∘•FLines
|
Day1 ⇐ {(⊑ ⋈ (+´3⊸↑)) ∨+´¨ •BQN⚇1 "" Split •FLines 𝕩}
|
||||||
# ⟨ 72602 207410 ⟩
|
# ⟨ 72602 207410 ⟩
|
||||||
|
|
||||||
Day2 ⇐ {
|
Day2 ⇐ {
|
||||||
|
@ -68,8 +68,8 @@ Day10 ⇐ {
|
||||||
# (but the string is a big banner)
|
# (but the string is a big banner)
|
||||||
|
|
||||||
Day18 ⇐ { # part 1 only :[
|
Day18 ⇐ { # part 1 only :[
|
||||||
grid ← (↕∘> 1+⌈˝)⊸∊ •BQN¨ '‿'⍟(=⟜',')⚇0 •FLines 𝕩
|
grid ← (↕∘> 1+⌈´)⊸∊ •BQN¨ '‿'⍟(=⟜',')⚇0 •FLines 𝕩
|
||||||
touch ← +´⥊ «‿» {∧⟜(𝕎⎉𝕩) grid}⌜ 1+↕3
|
touch ← +´⥊ «‿» {(𝕎⎉𝕩)⊸∧grid}⌜ 1+↕3
|
||||||
+´⥊ (6×grid)-touch
|
+´⥊ (6×grid)-touch
|
||||||
}
|
}
|
||||||
# 3470
|
# 3470
|
||||||
|
|
Loading…
Reference in a new issue