18
submitted 1 year ago* (last edited 1 year ago) by gerikson@awful.systems to c/notawfultech@awful.systems

Rules: no spoilers.

The other rules are made up as we go along.

Share code by link to a forge, home page, pastebin (Eric Wastl has one here) or code section in a comment.

you are viewing a single comment's thread
view the rest of the comments
[-] swlabr@awful.systems 1 points 11 months ago* (last edited 11 months ago)

Update to the update: now fully recovered, I am now trying to finish the last problems.

Solved 21 B!

I spent way too much time on this but it’s fineSo my approach to AOC has always been to write a pure coding solution, which finally broke down here.

First, the solve:

I call the unrepeated garden map the “plot”. Each repetition of the plot I call a “grid”. Hope that isn’t confusing.

  1. Looking at the input data, it is a grid of 131x131 squares with the starting position in the center at 66,66 (indexed from 1)
  2. If you imagine a chessboard pattern over the whole area, on each step the possible reachable squares alternate colors.
  3. Row 66 and col 66 are unimpeded by stones, as well as the edges of each grid. This means that:
  • starting from the initial grid, it takes 66 steps to enter a new grid. You enter a new grid on all sides.
  • a grid is always initially entered from the middle of an edge, either on one or two sides based on its position relative to the grids that are currently being considered.
  • each grid is independent of every other grid, except for the step where it is entered.

To see why that last point is true, consider that in order for another grid A to influence an adjacent grid B beyond the moment the adjacent grid is entered, there must be a reachable point further from the midpoint of the edge on the edge of A. However, because the middle row and column are free from rocks, this is never the case. Any influence from A reaches B too late, i.e. reachable squares on B from A will be reachable sooner from just travelling from the entry point on B.

  1. The number of steps is 131x100x2023 + 65.

So putting all this together, the way I got the answer was like this:

  1. Simulate the whole area for 65 + (5*131) steps (more than necessary)
  2. Print the number of reachable squares in the grid at 65 + 131n for n = 0-5
  3. Using pen and paper, determine some coefficients for some of the numbers that come up, add everything up in a calculator, and type that answer into AOC.

So I guess the answer I arrived at was what I’d been thinking I should be doing this whole time: a mix of simulating some of the problem and a decent amount of pen and paper work to get the solution out, rather than just pure coding. Fun!

this post was submitted on 01 Dec 2023
18 points (100.0% liked)

NotAwfulTech

367 readers
1 users here now

a community for posting cool tech news you don’t want to sneer at

non-awfulness of tech is not required or else we wouldn’t have any posts

founded 1 year ago
MODERATORS