1
10
submitted 10 months ago* (last edited 10 months ago) by CameronDev@programming.dev to c/advent_of_code@programming.dev

Day 25: Snowverload

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

2
19
submitted 11 months ago* (last edited 11 months ago) by Ategon@programming.dev to c/advent_of_code@programming.dev

Hey everyone! Thought I would do a post ahead of the event to cover the major topics that will probably come up


What is Advent of Code?

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.

Each day will have two different puzzles that must be solved in order (you get access to the second after solving the first). Each puzzle has the same backstory but each person has different input they get for that puzzle.

Puzzles are released every day at midnight ET and can be completed anytime after they are released (but people who solve them quicker after theyre been released get more points for the site leaderboard)

(Puzzles are on https://adventofcode.com)


What can I post here?

Anything relating to the event! Whether that be a meme, asking for help, sharing solutions, etc.

How should I format my post titles?

Try to keep titles in this general format:

[help, etc. category if applicable] [YEAR Day # (Part X)] [programming language if applicable] Post Title

For example:

[2023 Day #5 (Part 3)] [Rust] My attempt at a solution

Another example:

[Help] [2023 Day #2] What does this sentence mean

This helps people avoid spoilers and lets people use it as an archive by searching if they find out about the event in the middle and are starting from the beginning then

Should I post in the solution thread or separately?

If its just a solution try to keep it in the solution megathread so the community doesn't get spammed with solutions! If you add something onto that such as a doing a visualization, making it a meme, or etc. though feel free to post it separately

What can I post in the solution megathread?

The top level comments in the solution megathread should be solutions to that day. If you want to write something that is not a solution feel free to make a new post about it.

Any replies to top level comments though can be whatever


Lemmy-UI doesn't handle code blocks well, what do I do?

I pushed an update to lemmy-ui that adds code block support that will be arriving to all instances in version 0.19. This is currently in release clients and I expect it to release in the middle of the event.

For now though feel free to mirror any code you post onto some other site such as pastebin. if you can try to do both code blocks and pastebin to future proof it for when 0.19 eventually drops

To make a code block make three backticks, make a new line and put the code on lines, then put a newline and do three backticks on that

e.g.

```
console.log('Hello World')
```

becomes

console.log('Hello World')  

If your instance decided to beta test 0.19 you might be able to see code blocks already on the site, I put a code block above and in the sidebar so if one of those renders for you you have code block support

If youre using an app instead of the site though this section does not apply to you and depends on whether the developer of your app has added code block support or not

3
36
submitted 11 months ago* (last edited 11 months ago) by Ategon@programming.dev to c/advent_of_code@programming.dev

Hey everyone! I set up a private leaderboard for the programming.dev community so we can have one for the community in addition to the global one

The leaderboard code is 3316962-6587d422

Looking forward to seeing you guys there! Ill make a post at the end with the top people on the leaderboard and the version on the site will auto update as people complete challenges


Full instructions on Joining the Leaderboard

  • Log in on https://adventofcode.com/ using one of the methods such as through GitHub
  • Go to the leaderboard section in the navbar
  • Click the private leaderboard button on the page
  • Enter 3316962-6587d422 into the text box for entering a leaderboard join code
  • Click join

Update: Ive made a new leaderboard so that I could rename it to something that isnt just my username, the code there is updated to the new one that should be joined

4
25

AoC has ended for the year! Congrats to everyone who participated

Here are some stats from the instance leaderboard

Top 10 Users

  1. SekoiaTree
  2. Leo Uino
  3. Michon van Dooren
  4. funnyboy-roks
  5. PhiliPdB
  6. jhuang97
  7. Alex Utter
  8. hades
  9. JindΕ™ich IvΓ‘nek
  10. abclop99

Misc Stats

  • 91 Users got at least 1 star
  • 14 Users got 50 stars
5
40
6
28
7
10
submitted 10 months ago* (last edited 10 months ago) by CameronDev@programming.dev to c/advent_of_code@programming.dev

Day 24: Odds

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

8
13

Spoilers and explanation of solution:

Each vertex here is one intersection in our hike. We don't actually care about the parts in-between, because there's only one way to go. The above is a visualisation of the final path, the red edges are the edges taken. Our graph looks "like that" because it's a hiking trail, not a maze, so there's no dead ends. This took about 2 seconds to generate, due to all the cloning needed to keep track of paths. The two veeery long edges on the ends are pretty obvious choices, but one might notice that pretty much every vertex takes the two maximum paths it has, given the restrictions of the path. There's still some mildly surprising paths, such as (99, 29) -> (89, 37) with a weight of 38. I'm wondering if there's a way to dismiss more paths... This graph is actually pretty free in terms of movement.

My actual solution takes ~150 ms to run (and 8 microseconds for part one with barely any optimization, damnn)

9
9
submitted 10 months ago* (last edited 10 months ago) by CameronDev@programming.dev to c/advent_of_code@programming.dev

Day 22: A Long Walk

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

10
9
submitted 10 months ago* (last edited 10 months ago) by CameronDev@programming.dev to c/advent_of_code@programming.dev

Day 22: Sand

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

11
14
submitted 10 months ago* (last edited 10 months ago) by CameronDev@programming.dev to c/advent_of_code@programming.dev

Day 21: Step

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

12
13
submitted 10 months ago* (last edited 10 months ago) by CameronDev@programming.dev to c/advent_of_code@programming.dev

Day 20: Pulse

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

13
4
submitted 10 months ago* (last edited 10 months ago) by CameronDev@programming.dev to c/advent_of_code@programming.dev

Day 19: Aplenty

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

14
13
submitted 10 months ago* (last edited 10 months ago) by CameronDev@programming.dev to c/advent_of_code@programming.dev

Day 18: Lavaduct Lagoon

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

15
10

Anybody got some ideas to optimize today? I've got it down to 65ms (total) on my desktop, using A* with a visitation map. Each cell in the visitation map contains (in part 2) 16 entries; 4 per direction of movement, 1 for each level of straightaway. In part 2, I use a map with 11 entries per direction.

Optimizations I've implemented:

  • use a 2D array instead of a hashset/map. No idea how much this saves, I did it in the first place.
  • the minimum distance for a specific cell's direction + combo applies for higher combo levels as well for part 1. For part 2, if the current combo is greater than 4, we do the same*. Gains about 70(!!) ms
  • A* heuristic weighting optimization, a weight of about 1% with a manhattan distance heuristic seems to gain about 15 ms (might be my input only tho)

*Correctness-wise: the reason we're splitting by direction is because there's a difference between being at a cell going up with a 3 combo but a really short path, and going right with a 0 combo but a long path. However, this is fine because a 3 combo in the same direction as a 0 combo is identical, just more restrictive.

Optimizations that could be done but I need to ensure correctness:

the same optimization for the combo, but for directions. If I'm on a specific combo+direction, does that imply something about the distance for another direction? Simply doing the same for every non-opposite direction isn't correct

Code: https://codeberg.org/Sekoia/adventofcode/src/branch/main/src/y2023/day17.rs

Warning: quite ugly, there's like 8 copy-pastes for adding to the queue

16
14
submitted 10 months ago* (last edited 10 months ago) by CameronDev@programming.dev to c/advent_of_code@programming.dev

Day 17: Clumsy Crucible

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

17
18

Day 16: The Floor Will Be Lava

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

18
14
submitted 10 months ago* (last edited 10 months ago) by Ategon@programming.dev to c/advent_of_code@programming.dev

Day 15: Lens Library

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)
  • Code block support is not fully rolled out yet but likely will be in the middle of the event. Try to share solutions as both code blocks and using something such as https://topaz.github.io/paste/ , pastebin, or github (code blocks to future proof it for when 0.19 comes out and since code blocks currently function in some apps and some instances as well if they are running a 0.19 beta)

FAQ


πŸ”’ Thread is locked until there's at least 100 2 star entries on the global leaderboard

Edit: πŸ”“ Unlocked

19
22

Thought I'd share mine because most of the visualisations out there show the rocks sliding one cell at a time, all together. That looks nice but for my solution that's not how it works - I walk every row/col with two cursors.

Code here: https://github.com/sjmulder/aoc/blob/master/2023/c/day14.c

The visualisation is emitted right from the solution using a small library which dumps frames to ffmpeg.

20
24
submitted 10 months ago* (last edited 10 months ago) by Ategon@programming.dev to c/advent_of_code@programming.dev

Day 14: Parabolic Reflector Dish

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)
  • Code block support is not fully rolled out yet but likely will be in the middle of the event. Try to share solutions as both code blocks and using something such as https://topaz.github.io/paste/ , pastebin, or github (code blocks to future proof it for when 0.19 comes out and since code blocks currently function in some apps and some instances as well if they are running a 0.19 beta)

FAQ


πŸ”’ Thread is locked until there's at least 100 2 star entries on the global leaderboard

Edit: πŸ”“ Unlocked

21
13
submitted 11 months ago* (last edited 11 months ago) by Ategon@programming.dev to c/advent_of_code@programming.dev

Day 13: Point of Incidence

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)
  • Code block support is not fully rolled out yet but likely will be in the middle of the event. Try to share solutions as both code blocks and using something such as https://topaz.github.io/paste/ , pastebin, or github (code blocks to future proof it for when 0.19 comes out and since code blocks currently function in some apps and some instances as well if they are running a 0.19 beta)

FAQ


πŸ”’ Thread is locked until there's at least 100 2 star entries on the global leaderboard

πŸ”“ Unlocked

22
19
submitted 11 months ago* (last edited 10 months ago) by Ategon@programming.dev to c/advent_of_code@programming.dev

cross-posted from: https://programming.dev/post/7188393

This community still mostly has me running it and has 1 other mod but I typically like starting communities off with at least 2 mods. This community is a bit different in that theres the solution megathreads that need to be posted when a new day drops (and then unlocked when the global leaderboard fills up). When it has a dedicated mod team running it ill remove myself so its not admin run

If youre interested feel free to say so below

!advent_of_code@programming.dev

Note: to be a mod its preferred if your account is within the instance since lemmy doesnt handle cross-instance modding that well and this makes it so you have access to features added to pangora that other instances may not have

23
5

We all know and love (!) the leaderboard, but how about a different method?

One can solve a problem with a simple, naive method resulting in a short program and long runtime, or put in lots of explicit optimizations for more code and shorter runtime. (Or if you're really good, a short, fast program!)

I propose the line-second.

Take the number of lines in your program (eg, 42 lines) and the runtime (eg 0.096 seconds). Multiply these together to get a score of 4.032 line-seconds.

A smaller score is a shorter, faster program.

Similarly, (for a particular solver), a larger score is a "harder" problem.

24
7
submitted 11 months ago* (last edited 11 months ago) by purplemonkeymad@programming.dev to c/advent_of_code@programming.dev

So I managed to get part 1 of the day, but it took 2 seconds to run on the real input, which is a bad sign.

I can't see any kind of optimisation that means I can skip checks and know how many combinations are in those skipped checks (aside from 0.) I can bail out of branches of combinations if the info so far won't fit, but that still leads me to visiting every valid combination which in one of the examples is 500k. (And probably way more in the input, since if I can't complete the example near instantly the input is not happening.)

Right now I take the string, then replace the first instance of a ? with the two possible options. Check it matches the check digits so far then use recursion on those two strings.

I can try to optimise the matching, but I don't think that solves the real problem of visiting every combination.

I don't think (or hope) it's just bad code but this is my code so far (python.)

edit:

spoilera cache was the solution!

25
11
submitted 11 months ago* (last edited 11 months ago) by Ategon@programming.dev to c/advent_of_code@programming.dev

Day 12: Hot Springs

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)
  • Code block support is not fully rolled out yet but likely will be in the middle of the event. Try to share solutions as both code blocks and using something such as https://topaz.github.io/paste/ , pastebin, or github (code blocks to future proof it for when 0.19 comes out and since code blocks currently function in some apps and some instances as well if they are running a 0.19 beta)

FAQ


πŸ”’ Thread is locked until there's at least 100 2 star entries on the global leaderboard

πŸ”“ Unlocked after 25 mins

view more: next β€Ί

Advent Of Code

736 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