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.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
$ RL
$
$ AAA = (BBB, CCC)
$ BBB = (DDD, EEE)
$ CCC = (ZZZ, GGG)
$ DDD = (DDD, DDD)
$ EEE = (EEE, EEE)
$ GGG = (GGG, GGG)
$ ZZZ = (ZZZ, ZZZ)
TestInput ←
$ LLR
$
$ AAA = (BBB, BBB)
$ BBB = (AAA, ZZZ)
$ ZZZ = (ZZZ, ZZZ)
TestInputII ←
$ LR
$
$ 11A = (11B, XXX)
$ 11B = (XXX, 11Z)
$ 11Z = (11B, XXX)
$ 22A = (22B, XXX)
$ 22B = (22C, 22C)
$ 22C = (22Z, 22Z)
$ 22Z = (22B, 22B)
$ XXX = (XXX, XXX)
TestInputIII ←
ParseI ← (
⊓⊢≡(°[⊙⊙∘]≡°□↘1⊢regex"(.{3}) = \\((.{3}), (.{3})\\)")∩≡°□⊃↙↘1⊜□≠@\n.
⊙⊙⊙⊟⊃(∘|°⊟⊗"AAA"_"ZZZ"⋅∘|⊗:⋅⊙∘|⊗:⋅⊙⋅∘)
)
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"