File tree 1 file changed +28
-44
lines changed
1 file changed +28
-44
lines changed Original file line number Diff line number Diff line change 1
1
# https://adventofcode.com/2024/day/5
2
2
3
- # Uiua 0.14 .0-dev.6
3
+ # uiua 0.15 .0-dev.1
4
4
# Experimental!
5
5
6
- # &fras "input.txt"
7
- &fras "example.txt"
8
- °/$"_\n\n_"
9
-
10
- # ≡(□⊜□⊸≠@\n°□)
11
- # ≡(□°/$"_\n_"°□)
12
- ⍚°/$"_\n_"
13
- ∩°□:°⊟
14
-
15
- ParseFirst ← ≡(◇⊜⋕⊸≠@|)
16
- ParseSecond ← ≡(⍚⊜⋕⊸≠@,) ↘¯1 # last row is empty...
17
-
18
6
UpdateMap ← (
19
7
⊙⊃(⬚(□[])get|⊙∘):
20
8
insert:⍜(°□:)⊂
21
9
)
22
10
23
- ⊓($second ParseSecond|$first ∧(UpdateMap°⊟₂) :[] ParseFirst)
24
-
25
- S ←
26
- F ←
11
+ # map $ rules
12
+ 🗺 ← ∧(UpdateMap°⊟₂) :[]
27
13
28
- # $first ∧(UpdateMap°⊟₂) F $map []
29
- # # ⍜(?⬚(□[])get5?)(?□?⊂?:3°□?) # pattern match failed, bugg?
30
- # S
31
-
32
- # - för varje i second
33
- # - try get i first
34
- # - för varje i first
35
- # - jämför mot kvarvarande i second
14
+ # updates rules $ data
15
+ 🗄 ← (
16
+ °/$"_\n\n_"
17
+ ⍚°/$"_\n_"
18
+ ∩°□:°⊟
19
+ ⊓(≡(⍚⊜⋕⊸≠@,) ↘¯1|🗺≡(◇⊜⋕⊸≠@|))
20
+ )
36
21
37
- # first: rules
38
- # second: updates
39
- # both: pages
22
+ # - för varje update
23
+ # - try get i rules
24
+ # - för varje i rules
25
+ # - jämför mot kvarvarande updates
40
26
41
- S
42
- # ↙2
43
- $validrules ≡(
44
- ⇌°□
45
- ⇡⊸⧻
46
- ⊙¤
47
- ≡(↘
48
- ◇°⊂
49
- °□⬚[]get:F
50
- /∨∈:
51
- )
52
- /∨
53
- -:1
27
+ # bool $ update rules
28
+ IsCorrectlyOrdered ← (
29
+ ≡⌟◇(/∨◇∊: ⬚[]get ⊙: °⊂ ⇌) ⧅□
30
+ ¬/∨
54
31
)
55
- ▽:S
56
- /+≡(⊡⌊÷2⊸⧻°□)
57
32
58
- # 6498, correct
33
+ # answer $ updates rules
34
+ 🐪 ← (
35
+ ▽⤚≡⌟◇IsCorrectlyOrdered
36
+ ≡◇(⊡⌊÷2⊸⧻) # pick out the middle number
37
+ /+
38
+ )
39
+ ┌─╴🧪
40
+ ⍤⤙≍ 143 🐪 🗄 &fras "example.txt"
41
+ ⍤⤙≍ 6498 🐪 🗄 &fras "input.txt"
42
+ └─╴
You can’t perform that action at this time.
0 commit comments