Last active
December 3, 2021 13:49
-
-
Save ljos/33315829e1bc70b208d47e49d1c30133 to your computer and use it in GitHub Desktop.
adventofcode2021.bqn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p ← •BQN ¨ •file.Lines ⊑ •args | |
T1 ← +´1↓»⊸< | |
T2 ← +´˘3↕⊢ | |
•Show T1 p | |
•Show T1∘T2 p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val ← ⊐⟜' '⊸(↑⋈1↓↓)¨•Flines "ex-1.txt" | |
mov ← "forward"‿"down"‿"up"⊐(0⊑¨val) | |
amt ← •BQN¨1⊑¨val | |
•Show (×´+´) amt × mov ⊏ ⟨1‿0, 0‿1, 0‿¯1⟩ | |
F ← +´0⊑¨⊢ | |
D ← +´(1⊑¨⊢)×(+`2⊑¨⊢) | |
•Show (F×D) amt × mov ⊏ ⟨1‿1‿0, 0‿0‿1, 0‿0‿¯1⟩ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val ← ∾˘'1'=¨ •Flines "problem-01.txt" | |
Len ← {1⊣´≢𝕩} | |
Base2 ← +⟜(2⊸×)´∘⌽ | |
n ← Base2 ((Len val)÷2) < +´<˘val | |
m ← Base2 ((Len val)÷2) > +´<˘val | |
•Show n × m | |
OGR ← ⥊∘{x←𝕨⊑˘𝕩 ⋄ i←(0.5≤(+´x÷(Len 𝕩))) ⋄ (𝕨+1) {1<(Len 𝕩)}◶⊢‿𝕊 ((i⊑(⊔x))⊏𝕩)} | |
CSR ← ⥊∘{x←𝕨⊑˘𝕩 ⋄ i←(0.5>(+´x÷(Len 𝕩))) ⋄ (𝕨+1) {1<(Len 𝕩)}◶⊢‿𝕊 ((i⊑(⊔x))⊏𝕩)} | |
•Show (Base2 ∘ OGR val) × (Base2 ∘ CSR val) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment