Day 8: Playground
Megathread guidelines
- Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
- You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL
FAQ
- What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
- Where do I participate?: https://adventofcode.com/
- Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465


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.)
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)
# 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)Re. what connections to process or not? That seems to be like one of those that’s either completely obvious when you implement your solution one way, and a nasty pitfall when you do it another. In this case, pre-computing the list of pairs to process vs. finding the next one when you need it.
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.