::: spoiler My dirty hack
I broke the maze into SVR>FFT>DAC>OUT and SVR>DAC>FFT>OUT, realised that the latter was taking a suspiciously long time, so submitted just the answer from the former --> success!
:::
I've given up on Part 2. I knew what I needed to do but didn't have the understanding of how to use the matrix elimination method to get beyond the first stages. But I did find this:
::: spoiler How to solve part 2 without libraries
This is a solver written totally from scratch in Dart, so easily readable unlike some other languages :-):
[https://github.com/ayoubzulfiqar/advent-of-code/blob/main/2025/Dart/Day10/part_2.dart](GitHub link)
There's lots of parallelism (that's over the top for this problem), but the core solveSystem method is very clearly written, just long...
:::
Squeezing all spaces out of the grid (and plotting at right-angles to the other visualisation here) gives this evil shape, which will doubtless haunt my dreams tonight.
::: spoiler a hint that might help you
visualising the data reveals some interesting patterns. Follow link to do so.
:::
Any way, here's my Part 1 while I'm still thinking about this.
# AOC 2025 Day 09
# Experimental!
D ← &fras"AOC2025day09.txt" # Drop your file here and edit name
/↥/×+1⌵⍉/-⍉₂⧅<2⋕°csv D # Part 1
∧⍜⊡⋅1⟜(˜↯0+1/↥)⍜⍉≡⍜⍆⊛⋕°csv D # Visualised data
Part 2
This is basically me thinking out loud, so it's untidy, brutal, repetitive and slow. (20s in the pad)
link if you care
# Experimental!
# AOC 2025 Day 09
D ← "7,1\n11,1\n11,7\n9,7\n9,5\n2,5\n2,3\n7,3"
D ← &fras"AOC2025day09.txt" # Drop your file here and edit name
Parse ← ⋕°csv
Part₁ ← /↥/×+1⌵⍉/-⍉₂⧅<2
Squeeze ← ⍜⍉≡⍜⍆⊛ # Squeeze (add a sort to inspect)
Draw ← ∧⍜⊡⋅1⟜(˜↯0+1/↥) # Draw
HLines ← (
Squeeze Parse D
⍆⊕(□⍆)⊛⊸≡⊢
∧◇(⍜⊡˜⍜(⊏|˙=)⊙˜∘⊃(⊢⊢|↘⊙⇡°⊟+0_1⊣⍉))
)
VLines ← (
Squeeze Parse D
⍆⊕(□⍆)⊛⊸≡⊣
∧◇(⍜⊡˜⍜(⊏|˙=)⊙˜∘⊃(⊣⊣|↘⊙⇡°⊟+0_1⊢⍉))
)
DrawBorder ← ⍜⍉VLines HLines ˜↯0↯2+1/↥♭Squeeze Parse D # Draws full border
# DrawBorder Squeeze # running this shows these as key boundary points -> [219 121] [219 123]
# ⊏≡⌟˜⨂[[219 121] [219 123]]⊸Squeeze # which map to -> [[94985 48652][94985 50114]]
# leftmost -> only look left, rightmost-> only look right
# SO, now fill the shape to make this easier.
Fill ← (
⊙⊙1 # fill colour.
Good ← =0⊙◌⊡⊢ # Needs filling. Simple edges-check.
# Take first of list. If needs fill, do so and then add
# its four neighbours into queue. Repeat until queue is empty.
⍢(⨬(↘1|◴⊂+A₂¤°⊂ ⊃(⋅∘|∘|⋅⋅⋅∘)◡(⍜(⊡|⋅∘)⊢))◡Good
| >0⧻)
⋅⊙⋅
)
DrawBorder # Comment out everything below here to view the boundary.
Fill [219_120] # Now fill that boundary ([2_1] for test)
Squeeze Parse D
# ([0 1] for test)
[219 123] # [219 121] gave the wrong answer, so it's this.
≡⌞⊟ # couple this with every other point
# Extract the covered window of the array for each pair of corners.
# (Very probably doing this the hard way:-()
# Only keep those that are all 1.
▽⤚≡⌟(=1/×♭≡⌞⊏⊙⊏˜∘∩(↘⊙⇡°⊟+0_1⍆)°⊟⍉)
# Pick out our squeezed indices
⨂Squeeze Parse D
# Find out what the unsqueezed values were
˜⊏Parse D
# Find areas, return max.
/↥≡/×+1⌵≡/-
Yeah, that's one thing the gurus keep hammering home: anything you can move out of loop constructs (inc rows, partition, etc as well as the obvious do, repeat) and handle pervasively is a big win.
::: spoiler spoiler
Stupider than that: I'd just got halfway through writing a complicated divide and conquer algorithm to calculate nearest pairs when I realised that I could just brute-force it. :-)
:::
But yes, precomputing was definitely the way to go.
Just a messy part1 so far. Plus a moment of pure rage when I realised the trap.
(I have no idea what algorithm Lemmy uses to highlight Uiua code, but it's always a surprise.)
(edit: part 2 now added. I had a stupid error earlier. Takes 12s native or 20+s in the pad.)
::: spoiler Stupid error
I added elements just until the set first hit size 1, rather than continuing until total number of elements equalled number of points.
:::
# AOC 2025 Day 08
"162,817,812\n57,618,57\n906,360,560\n592,479,940\n352,342,300\n466,668,158\n542,29,236\n431,825,988\n739,650,466\n52,470,668\n216,146,977\n819,987,18\n117,168,530\n805,96,715\n346,949,466\n970,615,88\n941,993,340\n862,61,35\n984,92,344\n425,690,689"
N ← 10
L ← 20
# &fras"AOC2025day08.txt"◌ # Uncomment these three lines,
# N ← 1000 # drop your file onto this pane and correct that
# L ← 1000 # filename, to run this against your data.
# You will need to change settings>execution time to 30s or more.
Row ← (
⊙(⊃⊢↘₁)
⊚◡≡⌟◇(/+˜∊)
⨬(⊂⊙□◌ # Not found: new circuit
| ⍜⊡(⍜°□(◴⊂))⊢ # One found: add
| ▽>₀⊸≡◇⧻⍜(⊏|⊂{[]}{∘}◴/◇⊂) # Connect two
)⊸⧻◴
)
Parse ← ⍆⋕°csv
Sort ← ⊏⍏/+ⁿ2/-⊸⍉⊸⧅>2
IndexPrep ← {[°⊟]}⊸°⊂⊸≡⌟₁˜⨂
Part₁ ← ⊙◌/×↙3⇌⍆≡◇⧻⍥Row(-1N)
Part₂ ← /×⊢⍉⊏⊣↘¯⧻◌⍢(Row|<L/+≡◇⧻)
⊃(&p⍜nowPart₁)(&p⍜nowPart₂) &p⍜now(IndexPrep Sort Parse)
A bit late getting to this, but happy with this solution, despite it being nothing more than just building/summing all paths. As usual, you can drop your own file onto that solution.
D ← ".......S.......\n...............\n.......^.......\n...............\n......^.^......\n...............\n.....^.^.^.....\n...............\n....^.^...^....\n...............\n...^.^...^.^...\n...............\n..^...^.....^..\n...............\n.^.^.^.^.^...^.\n..............."
# D ← &fras"AOC2025day07.txt" # <- Uncomment and drop file here.
Parse ← ⊃↘↙1≠@.⊜∘⊸≠@\n
Flow ← ⊃(+⊃↻₁↻₋₁×|׬)⊙⊸⊣
P₁ ← /+>0♭⬚0×⟜∧(˜⊂↥Flow)
P₂ ← /+⊣∧(˜⊂+Flow)
⊃P₁ P₂ Parse D
Obviously very spoilery code, if you dare read it closely. try it here
It feels very anticlimactic to be ending so early in the month, but see you all next year!
huh?
Yes, it felt a little more like I was solving the puzzle-setter rather than the puzzle today.
There’s so many great features hidden behind ‘un’.
I’m sure that part2 could be simplified significantly but I was fed up by then.
Uiua
If it's stupid but it works...
::: spoiler My dirty hack I broke the maze into SVR>FFT>DAC>OUT and SVR>DAC>FFT>OUT, realised that the latter was taking a suspiciously long time, so submitted just the answer from the former --> success! :::
link (You'll need to up the execution limit)
I'm getting PTSD from today now.
Uiua
(added language tag)
Quiet here, isn't it?
Here's part1 to be going on with.
I've given up on Part 2. I knew what I needed to do but didn't have the understanding of how to use the matrix elimination method to get beyond the first stages. But I did find this:
::: spoiler How to solve part 2 without libraries This is a solver written totally from scratch in Dart, so easily readable unlike some other languages :-): [https://github.com/ayoubzulfiqar/advent-of-code/blob/main/2025/Dart/Day10/part_2.dart](GitHub link)
There's lots of parallelism (that's over the top for this problem), but the core
solveSystemmethod is very clearly written, just long... :::Squeezing all spaces out of the grid (and plotting at right-angles to the other visualisation here) gives this evil shape, which will doubtless haunt my dreams tonight.
Uiua
Part 1 was easy, part 2 is ...less so...
::: spoiler a hint that might help you visualising the data reveals some interesting patterns. Follow link to do so. :::
Any way, here's my Part 1 while I'm still thinking about this.
Part 2
This is basically me thinking out loud, so it's untidy, brutal, repetitive and slow. (20s in the pad) link if you care
Yeah, that's one thing the gurus keep hammering home: anything you can move out of loop constructs (inc rows, partition, etc as well as the obvious do, repeat) and handle pervasively is a big win.
I'm more like the sorcerer's apprentice watching my arrays get increasingly out of my control :-)
::: spoiler spoiler Stupider than that: I'd just got halfway through writing a complicated divide and conquer algorithm to calculate nearest pairs when I realised that I could just brute-force it. :-) ::: But yes, precomputing was definitely the way to go.
When I compare it to some other Uiua solutions on the Discord I feel like I'm still just banging rocks together.
That certainly doesn't reflect my mood today.
Thanks, 'Tis the season.
Uiua
Just a messy part1 so far. Plus a moment of pure rage when I realised the trap. (I have no idea what algorithm Lemmy uses to highlight Uiua code, but it's always a surprise.)
(edit: part 2 now added. I had a stupid error earlier. Takes 12s native or 20+s in the pad.)
::: spoiler Stupid error I added elements just until the set first hit size 1, rather than continuing until total number of elements equalled number of points. :::
Run it here(for what it's worth)
If took more code to animate this than it did to solve the problem...
Looks very nice for the test data:
And...okay...for the live data:
Uiua
A bit late getting to this, but happy with this solution, despite it being nothing more than just building/summing all paths. As usual, you can drop your own file onto that solution.
Looks good. I like how you managed to use the same structure for Parts 1 and 2; that's more than I did. And yours is faster than mine too.
Uiua
Messy code that might be worth revisiting later, but array handling is right up Uiua's street.