this post was submitted on 09 Dec 2025
17 points (87.0% liked)

Advent Of Code

1197 readers
28 users here now

An unofficial home for the advent of code community on programming.dev! Other challenges are also welcome!

Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Everybody Codes is another collection of programming puzzles with seasonal events.

EC 2025

AoC 2025

Solution Threads

M T W T F S S
1 2 3 4 5 6 7
8 9 10 11 12

Visualisations Megathread

Rules/Guidelines

Relevant Communities

Relevant Links

Credits

Icon base by Lorc under CC BY 3.0 with modifications to add a gradient

console.log('Hello World')

founded 2 years ago
MODERATORS
 

Day 9: Movie Theater

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

you are viewing a single comment's thread
view the rest of the comments
[–] mykl@lemmy.world 5 points 4 days ago* (last edited 3 days ago) (1 children)

Uiua

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

a hint that might help youvisualising 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βŒ΅β‰‘/-
[–] Quant@programming.dev 1 points 2 days ago (1 children)

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

[–] mykl@lemmy.world 1 points 2 days ago

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.