Skip to content

Instantly share code, notes, and snippets.

@ljos
Last active December 3, 2021 13:49
Show Gist options
  • Select an option

  • Save ljos/33315829e1bc70b208d47e49d1c30133 to your computer and use it in GitHub Desktop.

Select an option

Save ljos/33315829e1bc70b208d47e49d1c30133 to your computer and use it in GitHub Desktop.
adventofcode2021.bqn
p•BQN ¨ •file.Lines •args
T1+´1↓»<
T2+´˘3↕⊢
•Show T1 p
•Show T1T2 p
val' '(↑⋈1↓↓)¨•Flines "ex-1.txt"
mov"forward""down""up"(0¨val)
amt•BQN¨1¨val
•Show (×´+´) amt × mov 10, 01, 0¯1
F+´0¨
D+´(1¨)×(+`2¨)
•Show (F×D) amt × mov 110, 001, 00¯1
val˘'1'=¨ •Flines "problem-01.txt"
Len ← {1´𝕩}
Base2+(2×)´
nBase2 ((Len val)÷2) < +´<˘val
mBase2 ((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