Skip to content

Commit

Permalink
upgrade uiua version
Browse files Browse the repository at this point in the history
  • Loading branch information
KatieLG committed Dec 15, 2024
1 parent 70e44a8 commit 562666c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion AOC/uiua/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

Solutions to Advent of Code 2024 written in Uiua

Uses version 0.14.0-dev.2
Uses version v0.14.0-rc.1
9 changes: 3 additions & 6 deletions AOC/uiua/solutions/day06.ua
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Experimental!
~ "../helpers/input.ua" ~ ReadInput

Input ← (
ReadInput "day_06"
▽≠,@\r # remove carriage return
⊜∘≠,@\n # split on newlines
)

Expand All @@ -20,9 +18,8 @@ Neis ← (
)
FindPath ← (
⊂[¯1 0]⊢⊚⊸⌕@^ # start pos and direction
°□⊢ astar(
°□⊢ path(
1¤⊢Neis # neighbours with no rotation = lowest cost
| 0 # heuristic of 0
| ¬Valid↘₂ # keep going until out of grid
)
⊙◌ # discard the cost
Expand All @@ -34,9 +31,9 @@ IsLoop ← (

# Part A
◴≡↘₂FindPath Input # unique path positions
(&p⧻) # count (keep positions for part B)
# count (keep positions for part B)

# Part B
≡⍜⊡⋅@#⊙[Input] # put obstacles in each part A position
↘1 # but not starting position
&p/+≡IsLoop # sum up the loops
/+≡IsLoop # sum up the loops
5 changes: 1 addition & 4 deletions AOC/uiua/solutions/day10.ua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Experimental!

~ "../helpers/input.ua" ~ ReadInput

Input ← (
Expand All @@ -17,9 +15,8 @@ Nbrs ← (
▽:⊙(=1-:) # keep moves which are 1 increase
)
Trails ← (
astar(
path(
Nbrs # Neighbours have equal cost
| 0 # heuristic of 0
| =9⊡ # keep going until finding a 9
)
⊙◌ # discard cost
Expand Down
1 change: 1 addition & 0 deletions AOC/uiua/tests/test_solutions.ua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ SolutionMap ← map+1⇡15 Expected
GetSolution ← get⊙SolutionMap

TestDay ← (
⟜(&p $"Executing tests for day _" ↙₋₂$"0_")
GetSolution⊙(⇌⊟) # get the actual solution
⍤.≍ # assert matching
)
Expand Down

0 comments on commit 562666c

Please sign in to comment.