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"⋅∘|⊗:⋅⊙∘|⊗:⋅⊙⋅∘)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParseII ← (
|
|
|
|
|
|
|
|
⊓⊢≡(°[⊙⊙∘]≡°□↘1⊢regex"(.{3}) = \\((.{3}), (.{3})\\)")∩≡°□⊃↙↘1⊜□≠@\n.
|
|
|
|
|
|
|
|
⊙⊙⊙⊟⊃(∘|°⊟≡(⊚⌕)"AZ"¤≡(⊢⇌)⋅∘|⊗:⋅⊙∘|⊗:⋅⊙⋅∘)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PartI ← ⊙⋅⋅⋅;⍢⊃(
|
|
|
|
|
|
|
|
+1
|
|
|
|
|
|
|
|
| ⋅∘
|
|
|
|
|
|
|
|
| ⊡⊟⊗⊙"LR"⊡◿⧻,⊙⊙⊙⋅∘
|
|
|
|
|
|
|
|
| ⋅⋅⋅⊙∘
|
|
|
|
|
|
|
|
)(¬∊⋅⋅⊙∘) 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Lcm ← ×÷⊃(+⍢⊃◿∘(≠0×)⊃↧↥|⊙∘)
|
|
|
|
|
|
|
|
PartII ← /Lcm≡(PartI)¤⊙⊙∩¤
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PartI ParseI TestInput
|
|
|
|
|
|
|
|
PartI ParseI TestInputII
|
|
|
|
|
|
|
|
PartII ParseII TestInputIII
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PartI ParseI &fras "day08.in"
|
|
|
|
|
|
|
|
PartII ParseII &fras "day08.in"
|