day3 bqn 🥓

This commit is contained in:
rhiannon morris 2022-12-03 08:39:34 +01:00
parent ab5b9aec81
commit fa17b27096
1 changed files with 10 additions and 2 deletions

12
aoc.bqn
View File

@ -4,12 +4,20 @@ Sub ⇐ {a‿b𝕊𝕩:b↑a↓𝕩}
# e Split xs: split xs on occurrences of e (default 0)
Split {( 1¨(1)) Sub𝕩¨ (» ¨ -») /𝕨=𝕩(𝕨0)}
# n Chunk xs: split into chunks of length n (the last one might be smaller)
Chunk {(𝕨÷˜𝕩)𝕩}
Day1 ( (+´3))(+´¨)Split(•BQN0¨)•FLines
Day2 {
B (A {1+𝕩+3×3|1+𝕩-𝕨}) {3|𝕨+𝕩-1}
+´˘ (AB)´{asb:a-'A',b-'X'}˘ >•FLines 𝕩
}
•Show Day2 •args
# day 3 maybe later
Day3 {
Prio - "`&"('Z')
A +´ {(Prio¨×𝕩)𝕨}´(<˘ 2)¨
B +´ {abc:(Prio¨a)×b(a)c}¨(3Chunk)(¨)
(AB) •FLines 𝕩
}
# •Show Day3 ⊑•args