You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.0 KiB
Plaintext

1 year ago
$ 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⍉
Cycle ← (
⍜⍉SlideLeft # Up
SlideLeft # Left
⍜(⍉⇌)SlideLeft # Down
⍜≡⇌SlideLeft # Right
)
# this code is fucking awful
PartII ← (
¤Cycle
⍢(⊂Cycle⊢.)(¬∊⊃(⊢|↘1))
≡≍⊃↙↘1.
⊙(+1)∩(⊗1)⇌.
⍜(-|◿:)⊙1000000000
?
⊡-1⊙⇌
/+♭×⊃(-⇡.⧻⊢|=@O)
)
1 year ago
PartI Parse TestInput
PartII Parse TestInput
1 year ago
PartI Parse &fras "day14.in"
PartII Parse &fras "day14.in"