aoc2022/aoc.bqn

26 lines
902 B
BQN
Raw Normal View History

2022-12-02 01:19:46 -05:00
# a‿b Sub x: the b-length subarray starting at a
Sub {ab𝕊𝕩:ba𝕩}
# e Split xs: split xs on occurrences of e (default 0)
Split {( 1¨(1)) Sub𝕩¨ (» ¨ -») /w=𝕩(w𝕨0)}
2022-12-02 01:19:46 -05:00
2022-12-03 02:39:34 -05:00
# n Chunk xs: split into chunks of length n (the last one might be smaller)
Chunk {(𝕨÷˜𝕩)𝕩}
2022-12-02 02:41:12 -05:00
Day1 ( (+´3))(+´¨)Split(•BQN0¨)•FLines
# ⟨ 72602 207410 ⟩
2022-12-02 02:41:12 -05:00
Day2 {
B (A {1+𝕩+3×3|1+𝕩-𝕨}) {3|𝕨+𝕩-1}
2022-12-03 00:33:45 -05:00
+´˘ (AB)´{asb:a-'A',b-'X'}˘ >•FLines 𝕩
2022-12-01 14:37:22 -05:00
}
# ⟨ 17189 13490 ⟩
2022-12-03 00:33:45 -05:00
2022-12-03 02:39:34 -05:00
Day3 {
Prio - "`&"('Z')
A +´ {(Prio¨×𝕩)𝕨}´(<˘ 2)¨
B +´ {abc:(Prio¨a)×b(a)c}¨(3Chunk)(¨)
(AB) •FLines 𝕩
}
# ⟨ 7683 2488 ⟩