Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How do you structure your aoc project?

I tried doing Rust, but I'm too dumb to figure out if each day should be a module or if I should use lib (I guess?) files for each day and link everything to a main entry point.

Can you share your repo (if public)?



Take a look at my repo - http://github.com/nindalf/advent-2024

Each day is a new module, this way I don't have to think of new names for part1() and part2(). I can still import code from the rest of the crate if I want with `use crate::`.

If you like this style of structuring the project, you may be interested in the generator I use for it - http://github.com/nindalf/aocgen. `aocgen --day 2` will create these files and save you a bit of time. It will even download your problem input if you give it your adventofcode.com cookie.

Also check out https://codspeed.io/advent/day/1 for other Rust solutions that are aimed at being fast. They all use the same project structure. I wouldn't read the top 20 solutions though, they sacrifice readability and idiomaticity for speed.


Looks pretty neat I'll take some inspiration from this.

Though you shouldn't upload the text and inputs of the puzzles (maybe .gitignore them) as per [0]:

> Can I copy/redistribute part of Advent of Code? Please don't. Advent of Code is free to use, not free to copy. If you're posting a code repository somewhere, please don't include parts of Advent of Code like the puzzle text or your inputs. If you're making a website, please don't make it look like Advent of Code or name it something similar.

[0]: https://adventofcode.com/2024/about


I'm usually a rule follower, but this is a rule that I choose not to follow. I have a couple of reasons:

- I've spent effort on this, and I want the repository to work in future. I want to be able to clone it and run all the code without having to fetch the input once more, even if the site is unavailable. (I actually do this while benchmarking new hardware).

- I don't think it actually hurts the creator in any way, in my opinion. Here's an example: At least 660 people have uploaded inputs from 2022 (https://github.com/search?q=%22closest+beacon+is+at+x%22+pat...). These files have been up for 2 years. Exactly what injury has the creator suffered because of this? Are there people out there thinking "nah, it's too much effort to log into adventofcode.com, I'll just trawl GitHub repos for inputs and figure out what I'm supposed to do from there"? Obviously not.

So I have a compelling interest, and the creator hasn't articulated a good reason to avoid it. If he's able to articulate a good reason, then I'm willing to reassess my stance on this. He has my sympathy and full support if someone creates a lookalike site with the same puzzles and inputs but different CSS and without ads. That would be messed up. The potential injury is clear - he'd be losing users to the lookalike.

This is a subject of some controversy in the AOC community, but nothing I've read in those threads so far has been compelling. Anti-storage arguments usually just come down to "he's asking nicely so please comply". To which I politely respond that I don't accede to every polite request that comes my way.


I use a private submodule (hosted on my own infra) for the inputs, which addresses point 1. But I get where you're coming from.


That's smart! I'll probably do this too when I'll publish my AoC code




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: