|
|
@ -4,8 +4,9 @@ $ Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red
|
|
|
|
$ Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red
|
|
|
|
$ Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red
|
|
|
|
$ Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green
|
|
|
|
$ Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green
|
|
|
|
TestInput ←
|
|
|
|
TestInput ←
|
|
|
|
Colors ← {"red" "green" "blue"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Original parsing solution
|
|
|
|
|
|
|
|
Colors ← {"red" "green" "blue"}
|
|
|
|
Parse ← (
|
|
|
|
Parse ← (
|
|
|
|
⊔⊢⇌↘1 regex "Game (\\d+): (.*)"
|
|
|
|
⊔⊢⇌↘1 regex "Game (\\d+): (.*)"
|
|
|
|
⊜(□⊜(⇌⊜((parse⊔⋅∘|⊙;)<3.⊃(⊗⊙Colors|∘)□)≠@ .)≠@,.)≠@;.
|
|
|
|
⊜(□⊜(⇌⊜((parse⊔⋅∘|⊙;)<3.⊃(⊗⊙Colors|∘)□)≠@ .)≠@,.)≠@;.
|
|
|
@ -14,11 +15,22 @@ Parse ← (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Somewhat optimized second take on parsing
|
|
|
|
|
|
|
|
ColorsII ← "rgb"
|
|
|
|
|
|
|
|
ParseII ← (
|
|
|
|
|
|
|
|
↘+2⊗@:.
|
|
|
|
|
|
|
|
⬚0⊜(⊕∘⍘⊟⍉∵(⊟⊃(⊗⊙ColorsII⊢|parse↘2)⇌⊔) regex "\\d+ [rgb]")≠@;.
|
|
|
|
|
|
|
|
↯¯1_3
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
PartI ← /×≤12_13_14/↥
|
|
|
|
PartI ← /×≤12_13_14/↥
|
|
|
|
PartII ← /×/↥
|
|
|
|
PartII ← /×/↥
|
|
|
|
|
|
|
|
|
|
|
|
/+×+1⇡⧻.⊜(PartI Parse)≠@\n.TestInput
|
|
|
|
/+×+1⇡⧻.⊜(PartI ParseII)≠@\n.TestInput
|
|
|
|
/+×+1⇡⧻.⊜(PartI Parse)≠@\n.&fras "day02.in"
|
|
|
|
/+×+1⇡⧻.⊜(PartI ParseII)≠@\n.&fras "day02.in"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/+⊜(PartII ParseII)≠@\n.TestInput
|
|
|
|
|
|
|
|
/+⊜(PartII ParseII)≠@\n.&fras "day02.in"
|
|
|
|
|
|
|
|
|
|
|
|
/+⊜(PartII Parse)≠@\n.TestInput
|
|
|
|
⊙⋅∘⍜now⊜(□ Parse)≠@\n.&fras "day02.in"
|
|
|
|
/+⊜(PartII Parse)≠@\n.&fras "day02.in"
|
|
|
|
⊙⋅∘⍜now⊜(□ ParseII)≠@\n.&fras "day02.in"
|
|
|
|