advent-of-code/2022/day13/day13.bqn
2024-11-12 21:46:18 +01:00

27 lines
833 B
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.

Split,lf•Import"../bqn-libs/strings.bqn"
Parse•BQN{'⟩'¨((']'=𝕩)/)'⟨'¨(('['=𝕩)/)𝕩}
inParse¨>lfSplit¨(2lf)Split ¯1•FChars•args
Cmp{
𝕨((0==))𝕩 ? 𝕨(>-<)𝕩;
𝕨((0=))𝕩 ? 0;
0=𝕨 ? ¯1;
0=𝕩 ? 1;
0=𝕨(Cmp)𝕩 ? 𝕨(Cmp(1))𝕩;
0=𝕨 ? (𝕨)𝕊𝕩;
0=𝕩 ? 𝕨𝕊𝕩;
𝕨(Cmp)𝕩
}
•Show +´(×(1+))¯1=Cmp´˘in
_BubbleSort{Cmp _𝕣 in:
Bubble{
1𝕩 ? 𝕩;
1=((𝕩)in) Cmp (1𝕩)in ? (1𝕩)𝕊(𝕩)2𝕩;
(𝕩)𝕊1𝕩
}
Bubble(𝕩)𝕩
}
•Show ×´1+(Cmp _BubbleSort 26in)01