diff --git a/AOC/uiua/helpers/input.ua b/AOC/uiua/helpers/input.ua index 639487e..5d67ab6 100644 --- a/AOC/uiua/helpers/input.ua +++ b/AOC/uiua/helpers/input.ua @@ -1,9 +1,14 @@ +Strip ↚ ▽≠,@\r # remove any carriage returns + ReadInput ← ( &fras $"../data/_/dataset.txt" # read data - ▽≠,@\r # remove any carriage returns + Strip ) - -ReadSample ← ( +ReadSample₁ ← ( &fras $"../data/_/sample\_part\_one.txt" # read data - ▽≠,@\r # remove any carriage returns + Strip +) +ReadSample₂ ← ( + &fras $"../data/_/sample\_part\_two.txt" # read data + Strip ) diff --git a/AOC/uiua/solutions/day22.ua b/AOC/uiua/solutions/day22.ua index 59bc4d1..b8cc0b5 100644 --- a/AOC/uiua/solutions/day22.ua +++ b/AOC/uiua/solutions/day22.ua @@ -5,10 +5,19 @@ Input ← ( ⊜⋕≠,@\n ) -Xor ← °⋯⬚0≠∩⋯ # bitwise or -Mp ← ◿16777216 Xor # Mix and prune -Process ← Mp⊸×₂₀₄₈Mp⌊⊸÷₃₂Mp⊸×₆₄ # Process a secret +Xor ← °⋯⬚0≠∩⋯ # bitwise or +Mp ← ◿16777216 Xor # Mix and prune +Process ← memo(Mp⊸×₂₀₄₈Mp⌊⊸÷₃₂Mp⊸×₆₄) # Process a secret +Bananas ← ⇌◿10[⍥⊸Process2001] # bananas per secret +Diff ← -∩↘₁⊸↻₋₁◿10 # differences between bananas # Part A Input /+⍥Process2000 # sum up after 2000 iterations of processing + +# Part B +Input +⊸≡Diff≡Bananas # get differences between banana sales +◴♭₂≡(⧈∘4).⊙¤ # find the unique length 4 difference tuples +≡(/+≡⍣(⊡+4⊢⊚)0⌕)⊙¤ # find the sum of sales for each tuple +/↥ # take the best one diff --git a/AOC/uiua/tests/test_solutions.ua b/AOC/uiua/tests/test_solutions.ua index 633095a..401c029 100644 --- a/AOC/uiua/tests/test_solutions.ua +++ b/AOC/uiua/tests/test_solutions.ua @@ -18,6 +18,9 @@ Expected ← ( {"1,5,0,1,7,4,1,0,3" 47910079998866} # day 17 {322 "60,21"} # day 18 {226 601201576113503} # day 19 + {1363 1007186} # day 20 + {278748 ∞} # day 21 + {14726157693 1614} # day 22 ] ) SolutionMap ← map+1⇡⊸⧻Expected @@ -110,3 +113,9 @@ TestDay 18 now ~ "../solutions/day19.ua" TestDay 19 + +SkipDay 20 "Runtime is too long" + +SkipDay 21 "No solution" + +SkipDay 22 "Runtime is too long"