Thanks to visit codestin.com
Credit goes to programming.dev

  • 52 Posts
  • 423 Comments
Joined 3 years ago
Codestin Search App
Cake day: June 12th, 2023

Codestin Search App




  • mykl@lemmy.worldtoAdvent Of Code🧦 - 2025 DAY 11 SOLUTIONS - 🧦
    Codestin Search App
    Codestin Search App
    Codestin Search App
    2
    ·
    Codestin Search App
    26 days ago

    Uiua

    If it’s stupid but it works…

    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)

    # AOC2025day11 - mazes.
    # Uncomment for Part 1
    D  "aaa: you hhh\nyou: bbb ccc\nbbb: ddd eee\nccc: ddd eee fff\nddd: ggg\neee: out\nfff: out\nggg: out\nhhh: ccc fff iii\niii: out"
    # Uncomment for Part 2
    # D  "svr: aaa bbb\naaa: fft\nfft: ccc\nbbb: tty\ntty: ccc\nccc: ddd eee\nddd: hub\nhub: fff\neee: dac\ndac: fff\nfff: ggg hhh\nggg: out\nhhh: out"
    # D       &fras "randomAOC/AOC2025day11.txt"
    Tabs    (⊙□°⊂⊜∘¬⊸∊": ")⊸≠@\nD
    Nexts   (°□⊡˜⨂⊙Tabs|[])
    Part₁   ⊙◌⧻path(˙≠°⊏Nexts|≍"out")"you"
    
    Part₂  (
      ⊙◌⧻path(˙≠°⊏Nexts|≍"fft")"svr"
      ⊙◌⧻path(˙≠°⊏Nexts|≍"dac")"fft"
      ⊙◌⧻path(˙≠°⊏Nexts|≍"out")"dac"
      ××
    )
    # Only one will be right for the test data, depending on dataset.
    Part₁ Part₂
    


  • mykl@lemmy.worldtoAdvent Of Code🍗 - 2025 DAY 10 SOLUTIONS - 🍗
    Codestin Search App
    Codestin Search App
    Codestin Search App
    5
    ·
    Codestin Search App
    26 days ago

    Uiua

    (added language tag)

    Quiet here, isn’t it?

    Here’s part1 to be going on with.

    # AOC 2025 Day 10 - Wiring maze
    D ← "[.##.] (3) (1,3) (2) (2,3) (0,2) (0,1) {3,5,4,7}\n[...#.] (0,2,3,4) (2,3) (0,4) (0,1,2) (1,2,3,4) {7,5,12,7,2}\n[.###.#] (0,1,2,3,4) (0,3,4) (0,1,2,4,5) (1,2) {10,11,11,5,10,5}"
    # D      ← &fras"randomAOC/AOC2025day10.txt"
    Digits ← ⊜⋕⊸∊+@010
    Parse  ← ⊜(□⊜□⊸≠@\s)⊸≠@\n
    Part₁ ← (
      ≡◇(
        =@#↘₁↘₋₁°□°⊂↘¯1  # target
        ⊙⬚0≡◇(°⊚Digits)  # presses
        ⧻⊢path(≡⌞≠|=0/+) # find shortest path
      )
      /+-1
    )
    Part₁ Parse D
    

    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:

    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…



  • mykl@lemmy.worldtoAdvent Of Code🎁 - 2025 DAY 9 SOLUTIONS - 🎁
    Codestin Search App
    Codestin Search App
    Codestin Search App
    5
    ·
    Codestin Search App
    27 days ago

    Uiua

    Part 1 was easy, part 2 is …less so…

    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⌵≡/-
    







  • mykl@lemmy.worldtoAdvent Of Code🤶 - 2025 DAY 8 SOLUTIONS - 🤶
    Codestin Search App
    Codestin Search App
    Codestin Search App
    3
    ·
    Codestin Search App
    26 days ago

    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/+≡◇⧻)
    
    (&pnowPart₁)(&pnowPart₂) &pnow(IndexPrep Sort Parse)
    


  • mykl@lemmy.worldtoAdvent Of Code👪 - 2025 DAY 7 SOLUTIONS - 👪
    Codestin Search App
    Codestin Search App
    Codestin Search App
    4
    ·
    Codestin Search App
    29 days ago

    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.

    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
    


  • Uiua

    It took me a while to work out the merging of ranges, but I’m very pleased with the solution.

    Run it here

    D  "3-5\n10-14\n16-20\n12-18\n\n1\n5\n8\n11\n17\n32"
    # D  &fras"2025day05.txt" # drop your input file on this pane and uncomment this line to test against your own data.
    
    Parse  (⊜⋕⊸∊+@010)°□⊜□¬⊸⦷"\n\n"
    
    Merge  (
      (        # -> distinct, keep both.
      | ⊂⊢⟜(↥∩⊣) # -> overlap, merge them.
      )(≤⊓⊣⊢)
    | ⊙◌ # -> inside, ignore it.
    )(≤∩⊣)
    
    Ranges  ⊙◌⍥⍜⊣(Merge⊙°⊂)◡⋅⧻⊃↙↘1⍆↯∞_2 # Merge pairs of ranges.
    
    P₁  /+≡⌞(/↥≡⌟(↧⊓⌟≥≤°⊟))
    P₂  /+≡(+1/-)⊙◌
    P₁ P₂ Ranges Parse D