Using un-csv is smart :o
Much nicer to look at than the double partition I’ve been using so far
That part 2 scares me though :P
Using un-csv is smart :o
Much nicer to look at than the double partition I’ve been using so far
That part 2 scares me though :P
Part 1 only for now, probably not the most optimal solution (calculating all possible rectangles) but at least it’s short ^^
::spoiler Code
$ 7,1
$ 11,1
$ 11,7
$ 9,7
$ 9,5
$ 2,5
$ 2,3
$ 7,3
# &fras "input-9.txt" ◌
⊜(⊜⋕⊸≠@,)⊸≠@\n
⧅<2
≡(/×+₁-⊃↧↥°⊟)
/↥
:::
Not really proud of this one. Part 1’s still ok, just calculated all distances between boxes after realizing it’s not that many (499500, a reasonable amount I think, relatively speaking).
The dumbest thing I did this time was manually implementing the function to take the first n rows of an array by using a loop. Only when I was working on part 2 did I realize that I can just use the “take” function Uiua provides. Additionally, I even had some mistake in my reimplementation of it that only caused issues in part 2 somehow.
For anyone interested, it’s the commented out line in P₁ below.
Part 2 is just a brute force. For the actual input, I searched manually until I got to the pair number just before the actual solution because I didn’t want it to run that long and it takes long enough as is.
$ 162,817,812
$ 57,618,57
$ 906,360,560
$ 592,479,940
$ 352,342,300
$ 466,668,158
$ 542,29,236
$ 431,825,988
$ 739,650,466
$ 52,470,668
$ 216,146,977
$ 819,987,18
$ 117,168,530
$ 805,96,715
$ 346,949,466
$ 970,615,88
$ 941,993,340
$ 862,61,35
$ 984,92,344
$ 425,690,689
Dist ← ⍜(≡°√)/+⌵-°⊟
Prep ← (
⊜(⊜⋕⊸≠@,)⊸≠@\n
⧅<2
⊏⍏⊸≡Dist
)
Merge ← (
⍜♭₂⊛
{}
⍥(⍣(⊙(°⊂
□⍥(
⟜⊸˜≡⌟(>/+⊃⨂(×₂⋅⧻))
◴⊂⊙(♭∩⌟▽⟜¬)
)∞
)
⊂
| ∘)
)∞
⊙◌
)
P₁ ← (
Prep
# ⍥₁₀(⊙⤙⊡°˜⊂)
↙₁₀
Merge
⍆≡◇⧻
/×↙₋₃
)
P₂ ← (
Prep
1_0
⊸⍢(
⍜°˜⊟(
⊙+₁
⋅⟜↙
⊙(Merge
◇⧻⊢)
)
| <20⊣)
-₁⊢
⊡
×°⊟⊡₀⍉
)
[⊃P₁P₂]
≡(&p $"Part _: _") 1_2
Part 1 was fun, though I had quite some frustration with getting the loop work the way I wanted it to.
For part 2 I didn’t actually need to modify that much, just pass another function to deal with the list of tachyons: part 1, remove duplicates, part 2, don’t remove and count at the end. Easy. Or so I thought.
I realized something was wrong when it just wouldn’t stop running and the fan got louder.
Today I started over from scratch and decided to solve both parts at once since I basically got the counts for each row anyways, so I just had to change the way the splitting was handled.
There was one occasion where I got an error that the resulting array would be too big (~4GB) but at least I got a warning instead of seeing RAM usage spike suddenly :P
$ .......S.......
$ ...............
$ .......^.......
$ ...............
$ ......^.^......
$ ...............
$ .....^.^.^.....
$ ...............
$ ....^.^...^....
$ ...............
$ ...^.^...^.^...
$ ...............
$ ..^...^.....^..
$ ...............
$ .^.^.^.^.^...^.
$ ...............
# &fras "input-7.txt" ◌
⊜∘⊸≠@\n
⊃(=@S⊡₀)(⊏⊚>0⊸≡/+=@^↘₂)
ShootSplit ← (
⤚(=2+>0)
⧻⊸⊚
⊙(⟜₂(
⟜⊏⊚⊙⟜[⧻]
⍚(⊂⊃-₁+₁)
/+≡⌟(⬚0˜↯×◇°⊚)
)
+⍜⊏(˜↯0⧻)⊚
)
)
Solve ← (
0
⍥(⊙(+|ShootSplit|⊃⊡₀↘₁))◡⋅⋅⧻
⊟⊙⊙◌⊙/+
)
Solve
≡(&p $"Part _: _") 1_2
And for completeness sake:
Edit: Tried to scrape the old code together but seems like it doesn’t actually work like this. Probably just some small thing I missed but I don’t have the mental energy to take a look at this mess again :P
Prep ← ⊃(⊚=@S)⊜∘⊸≠@\n
Splits! ← (
˙⍤>0◡⋅⧻
⤚(=⧻⤙˜⨂)
∩⌟▽⊸¬
⊸⧻
⊙(♭≡[⊃-₁+₁]
^⊂)
)
Shoot! ← (
0
⍢(⊙(+
| ⍣Splits!^⊸⋅0
| ⊚=@^°⊂
)
| >0⋅⋅⧻)
)
PartOne ← (
&fras "input-7.txt"
Prep
⊙⋅◌Shoot!◴
)
PartTwo ← (
&fras "input-7.txt"
Prep
⧻⋅⊙◌Shoot!∘
)
( ͡° ͜ʖ├┬┴┬┴
One of us! One of us!
Nice use of the inversion, I always forget that’s a thing
This was fun :D
I had a fun experience just throwing the strings with both numbers and spaces at the parse function. In the online pad, everything worked out fine but running the same code on my input locally gave me a “invalid float literal” error.
I thought I’d missed some edge case in the real input again, like is often the case.
Turns out that the Uiua version I used locally had a bug that’s fixed in the latest build. For once it wasn’t directly my fault ^^
$ 123 328 51 64
$ 45 64 387 23
$ 6 98 215 314
$ * + * +
# &fras "input-6.txt" ◌
Calc ← (
↘₂⊛⊂"+*"/◇⊂
≡◇⨬(/+|/×)
/+
)
P₁ ← (
⊜(⊜□⊸≠@ )⊸≠@\n
⊃⊣↘₋₁
⊙(⍉≡₀◇⋕)
Calc
)
P₂ ← (
⊜∘⊸≠@\n
⟜⧻
⊓⍉(˜↯@ )
⊜(⊙(□≡⋕)⍜⍉(⊃(⊢⊣)↘₋₁))¬⤚≡⌟≍
Calc
)
1_2 [⊃P₁P₂]
≡(&p &pf $"Part _: ")
That’s a great addition :D
Running my own input I also noticed that your solution is a lot faster than mine (processing each roll individually). I’ll keep that 2D-rotation in mind for the future.

Quite simple this one. Part 2 still takes a few seconds because I’m essentially checking off each roll individually.
$ ..@@.@@@@.
$ @@@.@.@.@@
$ @@@@@.@.@@
$ @.@@@@..@.
$ @@.@@@@.@@
$ .@@@@@@@.@
$ .@.@.@.@@@
$ @.@@@.@@@@
$ .@@@@@@@@.
$ @.@.@@@.@.
⊜∘⊸≠@\n
=@@
Rolls ← ⍣(⧻⊚˙⍤)∞⊸⊡1_1
Removable ← (
⬚0⧈Rolls[3_3 1_1 1_1]
⊚≤4
)
Remove ← ⍜⊡(˜↯0⧻)
PartOne ← ⧻Removable
PartTwo ← (
⊙0
⍥(
⊙(⊙+⟜⧻)⟜Removable
˜Remove
)∞
◌
)
&pf "Part One: "
&p ⊸PartOne
&pf "Part Two: "
&p PartTwo
Before seeing mykl’s solution this was my solution for part 2
PartTwoOld ← (
0⊙0
⍢(⊙⊙◌
⊙⊸Removable
+⊙⊸⧻
⊙⊸Remove
| ¬≍◌)
⊙⋅◌
)
It’s basically the same, just that I used a while-do-loop, making the check for the ending condition myself (which took me a bit to get right because I still find loops in Uiua a bit confusing).
Using the repeat-loop as above also gets rid of the dip’s (⊙). I could’ve removed them here as well but I was already deep in the trouble of getting the loop to work correctly and I liked the little face at the beginning 0⊙0
My original solution for part 1 was just removing the last digit, get the highest number, cut off everything up to and including that first number, get the highest number again.
Once I did part 2 I realized I can just throw in a loop, cut off parts of the end so there’s enough numbers left for the subsequent iterations and keep the rest the same.
Now it works for any number of batteries and all you’d need to change is the number after Total! :D
Online pad: AoC-2025-D3
You can even use your own input by uploading a file (make sure it’s using LF line endings only with a trailing one at the end) and replacing the example input with this: &rs inf &fo "input-file.txt"
$ 987654321111111
$ 811111111111119
$ 234234234234278
$ 818181911112111
⊜∘⊸≠@\n
Max ← ⊢⊸⍖
Jolt! ← (
¯^
""
⍥(⊙(⤚⊡Max◡↘+₁
⊙(⊙↘⤚⋅∘+₁))
⊂
)^
⊙⋅◌
)
Total! ← (
≡(⋕Jolt!^)
/+
)
PartOne ← Total!2
PartTwo ← Total!12
⊸PartOne
&pf "Part One: "
&p
PartTwo
&pf "Part Two: "
&p
I too am suffering from TMA, but it’s related to archives instead of acronyms
Uiua
I’m currently going through the 2025 Quests to learn Rust, committing great sins along the way.
Decided to take a shot at the third one with Uiua because it looked nice and simple, and it was. This may have been the fastest I’ve ever finished a complete quest :P
Run with example input
Code