aoc2022/aoc.bqn

35 lines
1.1 KiB
BQN
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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)}
# n Chunk xs: split into chunks of length n (the last one might be smaller)
Chunk {(𝕨÷˜𝕩)𝕩}
Day1 ( (+´3))(+´¨)Split(•BQN0¨)•FLines
# ⟨ 72602 207410 ⟩
Day2 {
B (A {1+𝕩+3×3|1+𝕩-𝕨}) {3|𝕨+𝕩-1}
+´ (AB)´{"AX"-˜02𝕩}¨ •FLines 𝕩
}
# ⟨ 17189 13490 ⟩
Day3 {
Prio - 'Z'"`&"
A +´ {(Prio¨×𝕩)𝕨}´(<˘ 2)¨
B +´ {abc:(Prio¨a)×b(a)c}¨(3Chunk)(¨)
(AB) •FLines 𝕩
}
# ⟨ 7683 2488 ⟩
Day4 {
Line •BQN '‿'("-,")¨ # hehe
F {´´˘´1(32)𝕩˜𝕨-'a'}
A "cabddbac"F, B "cabcacda"F
+´ (AB)Line¨ •FLines 𝕩
}
# ⟨ 536 845 ⟩
# •Show Day4 ⊑•args