Summary for those just joining us:
Advent of Code is an annual Christmas themed coding challenge that runs from December 1st until christmas. Each day the coding problems get progressively harder. We have a leaderboard and pretty good turnout, so feel free to hop in at any time and show your stuff!
Whether you have a single line monstrosity or a beautiful phone book sized stack of OOP code, you can export it in a nice little image for sharing at https://carbon.vercel.app
What did you think about today's problem?
Our Code is 2416137-393b284c (No need to share your profile, you have the option to join anonymously if you don't want us to see your github)
Jump in the discussion.
No email address required.
i unfortunately missed this ine because i was getting drunk with my friends... oopsies. anyways still super ineberated and havent attwmpted it, i rlly ahte how this is scored because u have to be a nowlifer to get on the leaderboard :/
!codecels join the AoC hate train
Jump in the discussion.
No email address required.
More options
Context
wasted an ungodly amount of time reading stack traces with printed ascii grids and debugging because I zoned out and implemented "north, south, east, west" in one place as "up, down, left, right"
shan't doing part two, as I will be taking my own life, thank you for your understanding
Jump in the discussion.
No email address required.
More options
Context
I thought I had a solution to part 2 by just checking every cell and traversing until I hit an edge, but I didn't read the part that squeezing between pipes also counts and now I want to kill my elf
Jump in the discussion.
No email address required.
Yep I have my traversal part 2 done and losing the will to continue
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Ended up using pick's Theorem.
Jump in the discussion.
No email address required.
Can you explain how? I saw a bunch of reddit people saying the same thing and I don't understand how that works since you'd need to know the area of the interior to calculate the result. Unless I just don't understand the theorem which is also likely.
Jump in the discussion.
No email address required.
Use a Depth First Search, one item at a time, to get the entire pipe in order. Then use the shoelace formula to get the Area. From picks theorem,
A= i +b/2
where A is the area, i is the number of interior points (the answer to the puzzle) and b is the number of boundary points (the length of the pipe).
The 2nd illustration on the Wikipedia page is very useful. https://en.wikipedia.org/wiki/Pick%27s_theorem
Jump in the discussion.
No email address required.
More options
Context
prpbably spomething to do with the difference of the coordinates
Jump in the discussion.
No email address required.
That doesn't help even a little bit, but thanks I guess
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
More options
Context
Time flies when you're having fun
Jump in the discussion.
No email address required.
More options
Context
My part 1 was broken and couldn't figure it out, so i copy pasted like 10 solutions from the reddit solution thread that all gave me a wrong solution. And eventually I found the issue myself.
At the end the issue was that my F, moved exactly like the L. Otherwise it is just a simple dfs(and hoping that the longest contiguous part is the loop. But it would be easy to check if you reached S again. Also surrounded my entire pipe maze with one '.' in every direction, to not have to do bounds checking.
Part 2, whenever I find time later
Jump in the discussion.
No email address required.
Okay here is part 2. The only issue right now is that I have manually replace the 'S' with the appropriate symbol for part 2.
Actually was not that hard, but struggled a bit getting the logic of the raycasting right.
Basically to find out if a point is inside the loop polygon, you need traverse the row up to that point and count how many pipes were traversed.
|
counts as one pipe breakL followed by a 7
counts as one break (ofc consider any amount of - inbetween)F followed by J
counts as one breakF followed by 7 and L followed by J don't count.
The point is then in the polygon if breaks % 2 == 1.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
I hope writing my correct solution inside the debug block for my incorrect one makes my disdain for geometrystrags clear
Jump in the discussion.
No email address required.
hmm
i really gotta learn about those
I keep hearing about them
yet I continue to ignore them
Jump in the discussion.
No email address required.
I think it's just a dict for people who've done a DSA class
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
Part 1 was straight forward path finding, just annoying to keep track of indexes. I need to take a break and think about part 2
Jump in the discussion.
No email address required.
Kinda crazy to keep track of a max value when you can just find the length of the loop by traversing it once and divide by two
Jump in the discussion.
No email address required.
Thanks, that's a good trick. This is my first time doing coding puzzles so I'm suprised I'm keeping up tbh
Jump in the discussion.
No email address required.
I like seeing strange approaches to problems. It adds one more thing to the toolkit that might be needed later
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
It's simpler than path finding in that there is only ever one direction you can go, originally I thought I'd have to pull out A* and was relieved that it wasn't that kind of problem.
Jump in the discussion.
No email address required.
I think I went this way because you don't know the shape of S, but yeah, I could probably combine the neighbour finding and path building steps if I was smart about it
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Part 2 (algo from SO) and cleaned up because doing it with flat arrays was stupid
Jump in the discussion.
No email address required.
More options
Context
More options
Context
I had to do a Point In Polygon algorithm for computer vision class once and frankly I don't like it and just looked it up again. Rederiving algorithms is for suckers when half the pythoncels are just importing and using it directly.
Probably should clean it up and write a more general function for up, down, left, right movement but I don't care it's sunday and nice out I'm going outside.
Jump in the discussion.
No email address required.
More options
Context
Good morning, I hate grids
Jump in the discussion.
No email address required.
More options
Context
I wasted maybe 8 hours on this today before starting from scratch and solving it in 10 minutes. My main mistakes:
1. Not appreciating that there's only one path to take out of each pipe.
2. Trying to do BFS for part 2 to fill the middle, writing some horrendous code for the tunnel parts.
I got up to 170 lines of code, realised "something's not right here" and cheated a little by reading a help thread on the subreddit. Once I understood the idea that you're just looking for the area inside a shape then it was fine. I used
shapely
which definitely felt like cheating but I just don't care.Jump in the discussion.
No email address required.
More options
Context
I probably won't continue if the difficulty keeps ramping up. I have too much work to spend that much time on it every day, plus Nim doesn't have a great library ecosystem to solve these problems.
Part 1 was alright:
Part 2 was an abomination, half nim, half python, half Gimp.
1. Found the path in Nim and create a new input file with all non-path tiles zeroed out.
2. Used a python script to draw an image upscaled 3 times (140x3, 140x3), where each 3x3 pixels corresponds to a pipe pattern or a 3x3 red dot for non-pipes.
3. In Gimp bucket fill the outer wall, bucket fill the inner wall , select all pixels in inner wall, remove holes in selection (captures the non-pipes pixels), subtract a selection of the inner wall.
4. Read number of pixels in selection and divide by 9.
Prettier colours:
Jump in the discussion.
No email address required.
Operator overloading: Like most other languages, but with slightly better syntax. In addition, there are 19 different operator characters you can use to create arbitrary operators.
Stropping: Keywords like
proc
can be used as identifier names by enclosing them in backticks.set
vsstd/sets
:set
is for ordinal types with <=2^16 possible values, because "sets are implemented as high performance bit vectors."Jump in the discussion.
No email address required.
More options
Context
More options
Context
part 2 was written by the devil.
Jump in the discussion.
No email address required.
More options
Context
I feel like Yandev with this terrible code, but what I did was trace along the path while marking every orthogonal unoccupied square on the grid with either an L or R depending on whether it's on my relative left or right while I travel along the loop. Then I make the Ls and Rs spread out along orthogonal squares using BFS until there's no more unoccupied squares. From there, I can tell where L or R is the enclosed area because the other one will be touching the edge of the grid, and I can just count them to get the answer.
Jump in the discussion.
No email address required.
More options
Context
Part 2 was a pain in the arse today, but there are two ways I could imagine solving it:
shapely
is a fairly good library for this.I went for the latter, which is a bit slow but far less memory intensive.
Jump in the discussion.
No email address required.
Part 1 was really easy, so I was kind of figuring part 2 was going to throw a curveball. I did not expect it to be that much of a b-word to figure out on day 10 though. I also eventually did a polygon type solution, but if I could go back in time, I think I would have done the flood fill you mentioned instead. I probably could have saved myself a couple frustrating hours.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
frick, my part 2 works only with the first example, not the next example where it's doubly enclosed. gonna kms later, bye girls.
Jump in the discussion.
No email address required.
nvm I got it
Jump in the discussion.
No email address required.
More options
Context
More options
Context
I did not enjoy trying to figure out what constitutes an edge or a vertex in Part 2. This was a clever way on the puzzle designer's part to turn something that should have been relatively simple into a total god darn nightmare.
Code for both parts:
Jump in the discussion.
No email address required.
More options
Context
Your sponsor code doesn't work
Jump in the discussion.
No email address required.
Are you inputting it on the right page
Jump in the discussion.
No email address required.
i'm pretty sure?
Here, right?
Jump in the discussion.
No email address required.
It literally says right under the box "not for private leaderboard codes"
Jump in the discussion.
No email address required.
I know I found it already, I concede I'm r-slurred
Jump in the discussion.
No email address required.
More options
Context
More options
Context
No wait wrong page, I've got it now. Ignore me, I'm a fricking r-slur
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
More options
Context
mann I tried the 2nd part but my caveman method of just marking from the outside-in didn't work & I'm partial about making a maze algorithm rn
Jump in the discussion.
No email address required.
More options
Context
Snapshots:
https://carbon.vercel.app:
ghostarchive.org
archive.org
archive.ph (click to archive)
https://adventofcode.com/2023:
ghostarchive.org
archive.org
archive.ph (click to archive)
Jump in the discussion.
No email address required.
More options
Context