this post was submitted on 11 Dec 2023
12 points (100.0% liked)

Advent Of Code

761 readers
1 users here now

An unofficial home for the advent of code community on programming.dev!

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.

AoC 2023

Solution Threads

M T W T F S S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25

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 1 year ago
MODERATORS
 

I wanted to show how the maze follows from individual letters but it was way too large

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 10 months ago (3 children)

There is a really simple approach that I describe in my comment on the megathread, but it's always good to have a nice visualisation so thanks for sharing!

[–] [email protected] 2 points 10 months ago (2 children)

Counting line crossings? I'm not sure what that means

[–] [email protected] 3 points 10 months ago* (last edited 10 months ago) (1 children)

Imagine you're looking at a grid with your path drawn out on it. On any given row, start from the left and move right, cell by cell. You're outside the area enclosed by your path at the start of the row. As you move across that row, you remain outside it until you meet and cross the line made by your path. Every non-path cell you now pass can be added to your 'inside' count, until you next cross your path, when you stop counting until you cross the path again, and so on.

In this problem, you can tell you're crossing the path when you encounter one of:

  • a '|'
  • a 'F' (followed by 0 or more '-'s) followed by 'J'
  • a 'L' (followed by 0 or more '-'s) followed by '7'

If you encounter an 'F' (followed by 0 or more '-'s) followed by '7', you've actually just skimmed along the line and not actually crossed it. Same for the 'L'/ 'J' pair.

Try it out by hand on the example grids and you should get the hang of the logic.

[–] [email protected] 2 points 10 months ago

Ah I see, I'll go back and try once I have some extra time. Thanks.