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.

39 lines
1.2 KiB
Plaintext

This file contains ambiguous Unicode characters!

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.

# NOTE: `Parse` and `ParseII` are out-of-date as of Uiua 0.5
$ Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green
$ Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue
$ 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 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green
TestInput ←
# Original parsing solution
Colors ← {"red" "green" "blue"}
Parse ← (
°□⊢⇌↘1 regex "Game (\\d+): (.*)"
⊜(□⊜(⇌⊜((⋕°□⋅∘|⊙;)<3.⊃(⊗⊙Colors|∘)□)≠@ .)≠@,.)≠@;.
≡(
∧(⍜⊡+⊙:°⊟)⊃°□0_0_0
)
)
# Somewhat optimized second take on parsing
ColorsII ← "rgb"
ParseII ← (
↘+2⊗@:.
⬚0⊜(⊕∘°⊟⍉∵(⊟⊃(⊗⊙ColorsII⊢|⋕↘2)⇌°□) regex "\\d+ [rgb]")≠@;.
↯¯1_3
)
PartI ← /×≤12_13_14/↥
PartII ← /×/↥
/+×+1⇡⧻.⊜(PartI ParseII)≠@\n.TestInput
/+×+1⇡⧻.⊜(PartI ParseII)≠@\n.&fras "day02.in"
/+⊜(PartII ParseII)≠@\n.TestInput
/+⊜(PartII ParseII)≠@\n.&fras "day02.in"
⊙⋅∘⍜now⊜(□ Parse)≠@\n.&fras "day02.in"
⊙⋅∘⍜now⊜(□ ParseII)≠@\n.&fras "day02.in"