tvl-depot/users/sterni/exercises/aoc/2022/09/9.bqn
sterni 42a4f14878 feat(sterni/aoc/2022): day09 BQN solution
Change-Id: Idad006eaacbd89827feb5bbd9d6e04605743fca2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7555
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
2022-12-10 18:36:09 +00:00

17 lines
598 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.

SplitOn,ReadDec •Import "../../lib.bqn"
i ReadDec(1)¨ (<' ')SplitOn¨ •FLines "input"
UnitDelta (÷(|+0=))
ExpandStep {
𝕊 "L"l: 𝕊 (-l)0;
𝕊 "R"r: 𝕊 r0;
𝕊 "U"u: 𝕊 0u;
𝕊 "D"d: 𝕊 0(-d);
𝕊 delta: ((´|)<UnitDelta) delta
}
Step {knots 𝕊 delta: {h 𝕊 t: (UnitDelta h-t) +(1<´|h-t) t}` (delta+) knots}
Visited {+´0=(¯1)¨(<𝕨<00) Step` ExpandStep¨ 𝕩}
•Out "day09.1: "•Fmt 2 Visited i
•Out "day09.2: "•Fmt 10 Visited i