-
Notifications
You must be signed in to change notification settings - Fork 0
/
day19.ua
45 lines (41 loc) · 1.16 KB
/
day19.ua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+@\0&ru0 0
°{⊙∘}⊜(□⊜□≠@\n.)¬⌕"\n\n".
↻⊢⊚∵⊔(≍"in"↙2). # Rotate so "in" state is first
⊂{"R{R}""A{A}"} # Add stable reject and accept states
:¤¤∵⊔(∩□⊃↙↘⊗@{.) # Separate labels and rules
≡(
⊜□≠@,.↘¯1↘1°□
⍜(°□⊢⇌|⊂"x<∞:") # Give default always true predicate
□≡(
⊃↙(⊗□↘+1)⊗@:.°□ # Look up label indices
⊃(⊗:"xmas"⊢|=@>⊡1|⋕↘2)
[⊙⊙⊙∘] # [x|m|a|s <|> value next]
)
)
Rules ← # [R A in …]
≡⊔(⊜⋕∊,+@0⇡10)
Parts ←
UpdateOne ← ≡(
∩⊡⊙(Parts|Rules)
:⊙:≡⊃↙⊡3°□:¤
≡(⊡:⊙°[⊙⊙∘])
⊡⊢⊚<∩×,:-¬.:
)⇡⧻.
PartOne ← /+♭▽:Parts⍢UpdateOne(/↥>1)↯⧻Parts2
UpdateTwo ← (
⊃⊢(↘1)
°{⊙∘}
°□⊡:Rules
⊙:≡⊃↙⊡3
⊙⊙(↯0_4_2[])
∧(
:⊙°[⊙⊙∘]:
⊃(⊟⊙⊃(,⊙¬)⋅+|⊟⊙⊃,⋅+)
⊙⊂∩⍜⊡(⍜∩×↥,:-¬.:)
)
⊂:▽⊃≡(/↧≡/<)≡(⊟:∩□)⇌◌
∩▽⊙,⊃=>1≡°□≡⊢.
⊙+:/+≡(/×≡/-⊔≡⇌⊢⇌)
)
PartTwo ← ◌⍢UpdateTwo(±⧻)¤{2[⍥4001_1]4}0
(PartOne|PartTwo) -1⋕⊡1&args