Fork me on GitHub
#adventofcode
<
2023-12-10
>
wevrem06:12:47

Day 10 - Solutions

wevrem06:12:30

I have my stars for Day 10, but boy it was a slog. I’ve got to clean up my code a bit before I post. Probably in the morning (my morning).

🤪 1
norman07:12:19

https://gitlab.com/maximoburrito/advent2023/-/blob/main/src/day10/main.clj I couldn't figure out how to make what I thought was the obvious solution work, so instead I literally converted the pipe map to 3x size so I could do a trivial bfs to find what is inside and outside. Looking at @UTFAPNRPT's solution, I'm still not entirely sure why it works and why you don't have to also check vertically, but I'm sure it'll make more sense in the morning 🙂

erdos07:12:49

https://github.com/erdos/advent-of-code/blob/master/2023/day10.clj For the second part, I went through the path again and cleared all other cells. Then I went thought the path the third time and kept track of the cells to my left hand side and used these as an input to a flood fill.

wevrem07:12:17

I did an https://en.wikipedia.org/wiki/Point_in_polygon algorithm for determining whether a point is inside a polygon. I tried to be fancy and check along rows or columns depending on which edge was closer, but I gave that up and just checked ‘above’.

👍 1
erdos07:12:44

looks like we have 3 merely different approaches so far.

wevrem07:12:06

The trick was that if these types of patterns are above a point:

7   F
|   |
J   L
they don’t count as crossing, but these do count:
7   F
|   |
L   J
and obviously
-
counts as a crossing.

😍 3
👏 1
alekszelark09:12:07

@UTFAPNRPT thanks a lot for pointing to https://en.wikipedia.org/wiki/Point_in_polygon and the trick, it helped me solve the part 2 🙌:skin-tone-2:. I’m not good at geometry ☺️

rjray18:12:43

Also used the even-odd rule for part 2. Part 1 was fun, if kind of long to code. I'll be revising this code later; I have some hard-coded values I don't like to see. https://github.com/rjray/advent-2023-clojure/blob/master/src/advent_of_code/day10.clj

👏 1
Ivana18:12:22

Nice task! For part 2 after unsuccessful tries with ray-crossing etc finally I just zoomed input field in 2 times, fill the area and check allinitial tiles in filled set. A bit surprized that we have to calculate all internal tiles (not only ground), so I had to make my zoom pipes different than initial ones.

genmeblog19:12:27

Here is how the pipe looks like.

🔥 4
☝️ 1
Felipe20:12:48

I'm so close, but my flood fill is filling everything 😕

Ivana20:12:34

And mine zoomed x2

Felipe00:12:44

I got it! spent more than one hour looking for a hole in my flood fill. off by one error; turns out I was skipping the position adjacent to the starting one. for part 2 I decided to zoom in like @U05T4JC21J6

(def expand
  {\| [".X."
       ".X."
       ".X."]
   \- ["..."
       "XXX"
       "..."]
   \L [".X."
       ".XX"
       "..."]
   \7 ["..."
       "XX."
       ".X."]
   \J [".X."
       "XX."
       "..."]
   \F ["..."
       ".XX"
       ".X."]
   \. ["..."
       "..."
       "..."]})
debugging this one was a chore, but very satisfying to get it right at the end https://github.com/FelipeCortez/advent-of-code/blob/master/2023/10.clj

danielneal15:12:23

Omg day 10 took far too long, I think it’s time for me to bow out of advent of code so I have some headspace for my real job https://github.com/danielneal/advent-of-code-2023/blob/main/src/day10.clj

alpox20:12:10

This one took me much too long and the code didn’t end up nice either 😕 at least its solved… Also went with the even-odd rule