|
|
|
@ -0,0 +1,32 @@
|
|
|
|
|
$ O....#....
|
|
|
|
|
$ O.OO#....#
|
|
|
|
|
$ .....##...
|
|
|
|
|
$ OO.#O....O
|
|
|
|
|
$ .O.....O#.
|
|
|
|
|
$ O.#..O.#.#
|
|
|
|
|
$ ..O..#O..O
|
|
|
|
|
$ .......O..
|
|
|
|
|
$ #....###..
|
|
|
|
|
$ #OO..#....
|
|
|
|
|
TestInput ←
|
|
|
|
|
|
|
|
|
|
Parse ← ⊜∘≠@\n.
|
|
|
|
|
|
|
|
|
|
# the `n`th triangle number
|
|
|
|
|
Triangle ← ÷2×+1.
|
|
|
|
|
|
|
|
|
|
# trans: switch from sliding north to sliding west, more convenient to work with
|
|
|
|
|
PartIOriginal ← (
|
|
|
|
|
⊃(
|
|
|
|
|
-⊃(+1≡(□⊂¯1⊚)=@#|⧻⊢)
|
|
|
|
|
| ≡(□⇌∧((⍜⊢(+1)|⊂0|∘)⊗⊙"O#")⊙[0])
|
|
|
|
|
)⍉
|
|
|
|
|
/+≡(/+-≡⊃(Triangle-:|Triangle)∩°□)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
SlideLeft ← ≡(⍜⊜□(≡(□⊐/⊂⊕□∩°□)=@..)≠@#.)
|
|
|
|
|
PartI ← /+♭×⊃(¤-⇡.⧻⊢|=@O)SlideLeft⍉
|
|
|
|
|
|
|
|
|
|
PartI Parse TestInput
|
|
|
|
|
|
|
|
|
|
PartI Parse &fras "day14.in"
|