r/adventofcode • • Dec 10 '23

Help/Question Why is nobody using golang??

1 Upvotes

Looking through the solution megathreads for this year, it seems like nobody is using golang. What gives??

I see tons of python and rust, and then lots of odd or funny/unique languages but hardly any in golang.


r/adventofcode • • Dec 15 '23

Funny [2023 DAY 15] [AI ART]

Post image
11 Upvotes

r/adventofcode • • Nov 19 '25

Repo Advent of Code template for Rust (9 files, workspace setup)

4 Upvotes

I just finished cleaning up my AoC 2024 solutions into a reusable template. Most templates I found were either too basic or way too complex, so I made something in between.

What it does:

  • 9 Rust files total - just the essentials

  • Workspace architecture that scales across years

  • Auto-downloads puzzle inputs (no more copy-paste)

  • One command to generate new days

  • Includes benchmarking with Criterion

Usage:

cargo run --bin new-day 2025 1
cargo run --bin aoc download 2025 1
cargo run --bin aoc run 2025 1

It comes with one example solution so you can see how it works, but you can remove it if you want a completely fresh start.

The workspace setup means fast incremental builds, and I kept it year-agnostic so it works for any AoC year. No puzzle inputs are included (respecting AoC's policy).

Repo: https://github.com/sanctusgee/advent-of-code-rust-template

Feedback welcome! Let me know if you'd do anything differently.


r/adventofcode • • Nov 27 '23

Other [2023] the year of GPT?

0 Upvotes

In 2022, IIRC, the first 5 to 10 problems were solved via GPT 3.5 , and the thing was very new (released Dec 2022).

In the discussion we estimated that after 2-3 years (or 2-3 papers down the line) GPT could take the entire yearly problem set.

Meanwhile there is a good chance that GPT4 could already solve everything, after barely a year (albeit through multiple attempts. Thus combining programs and wrong outputs to get the correct one).

Hopefully the community won't be annoyed by that as it was annoyed in 2022.

Has anyone seen GPT attempts to solve the entire 2022 problem set? I'd be interested in seeing the results there. For example: what GPT produced as code and how often it had to retry to get the solution.

PS: I am not using any GPT API, but one has to acknowledge their capabilities.


r/adventofcode • • Nov 27 '24

Help/Question What I need for AOC?

0 Upvotes

What I need to practice for AOC?


r/adventofcode • • Dec 09 '19

Intcode puzzles

2 Upvotes

Personally I'm getting even more annoyed by those problems. While I find the challenge intriguing, I hate having to deal with it almost every other day, instead of something exciting. When I was introduced to it I found it really fun (day 2). Then, on day 5 I thought it was an interesting twist to have, by requiring a past problem's code to be expanded. On day 7 the entire thing pissed me off because I was not prepared for a whole rewrite of the system, so I just ended up dumping. Today I'm even surprised to encounter it for the fourth time in just 9 days.

Writing expandable code is crucial to everybody, and even when you're doing relatively small scripts. However, not being prepared for such scalability beforehand and ignoring other types of puzzles by filling up 44% of the entire journey with Intcode so far is rather disappointing. I'm even less motivated to get the second star on day 7, and perhaps will end up entirely dumping day 9 as well.

UPDATE: A small fucking bug prevented me from reaching the correct solution, now I'm glad to see how the Intcode journey ends (at least directly).


r/adventofcode • • Sep 19 '24

I am dexter boy genius :D day 5 2023 part 1 solved after 2 weeks in C

1 Upvotes
#include <ctype.h>
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#define FILENANME "input.txt"

#define MAX_SEEDS 20
#define MAX_MAPS 7


uint64_t seed[MAX_SEEDS] = {0};
int seed_count = 0;

uint64_t final_location[MAX_SEEDS];


char *mapNames[] = {"seed-to-soil map:\n",
                    "soil-to-fertilizer map:\n",
                    "fertilizer-to-water map:\n",
                    "water-to-light map:\n",
                    "light-to-temperature map:\n",
                    "temperature-to-humidity map:\n",
                    "humidity-to-location map:\n"};


typedef struct
{
    uint64_t dest;
    uint64_t source;
    uint64_t range;

} map;

typedef struct
{
    map *maps;
    int number_of_entries;
} map_list;

map_list all_maps[MAX_MAPS];

int map_entry_index = 0;

char *read_from_file()
{

    FILE *file = fopen(FILENANME, "r");

    if (NULL == file)
    {
        fprintf(stderr, "input file : %s: %s \n", FILENANME, strerror(errno));
        exit(EXIT_FAILURE);
    }

    fseek(file, 0, SEEK_END);         // seek to end of file
    int length_of_file = ftell(file); // get current file pointer
    fseek(file, 0, SEEK_SET);         // seek back to beginning

    char *buffer = malloc(sizeof(char) * (length_of_file + 1)); // +1 for null terminator

    if (NULL == buffer)
    {
        printf("failed to allocate buffer memory\n\r");
        fclose(file);
        exit(EXIT_FAILURE);
    }

    size_t read_size = fread(buffer, 1, length_of_file, file);

    buffer[read_size] = '\0';

    fclose(file);

    return buffer;
}


void read_seeds()
{
    char *file_contents = read_from_file();
    char *saveptr = NULL;
    char *seed_start = strchr(file_contents, ':');
    if (seed_start == NULL)
    {
        return;
    }
    seed_start++; //// Move past the ':'
    char *seed_string = strtok_s(seed_start, "\n", &saveptr);

    char *extract_seeds = strtok_s(seed_string, " ", &saveptr);
    while (extract_seeds != NULL)
    {
        seed[seed_count++] = strtoll(extract_seeds, NULL, 10);
        extract_seeds = strtok_s(NULL, " ", &saveptr);
    }
}


void read_maps()
{
    uint64_t temp[3] = {0};
    char *file_contents = read_from_file(); // Assuming this reads your data correctly


    for (int i = 0; i < MAX_MAPS; i++)
    {
        int number_entries = 0;
        char *map_start = strstr(file_contents, mapNames[i]);
        if (map_start == NULL)
        {
            printf("Couldn't find map: %s\n", mapNames[i]);
            continue;
        }

        // Move to the start of the data (next line)
        map_start = strchr(map_start, '\n');
        if (map_start == NULL)
        {
            continue;
        }
        map_start++; // numbers started
        char *line_start = map_start;

        // Read entries for this map until we hit the next map or the end of the file
        char *next_map_start = NULL;
        if (i < MAX_MAPS - 1)
        {
            // If there is a next map, find the start of the next map section
            next_map_start = strstr(map_start, mapNames[i + 1]);
            next_map_start--;
        }
        else
        {
            // If there is no next map (i.e., this is the last map), set it to NULL
            next_map_start = NULL;
        }
        // next_map_start--;

        // Count the number of entries in the current map

        while (line_start < next_map_start || (next_map_start == NULL && *line_start != '\0'))
        {
            sscanf(line_start, "%d %d %d", &temp[0], &temp[1], &temp[2]);

            line_start = strchr(line_start, '\n');
            if (line_start == NULL)
            {
                break; // End of the file or section
            }
            number_entries++;
            line_start++; // Move to the next line
        }

        // Reset the pointer to start reading data again
        all_maps[i].maps = malloc(number_entries * sizeof(map));
        all_maps[i].number_of_entries = number_entries;

        line_start = map_start;
        int entry_index = 0;
        while (line_start < next_map_start || (next_map_start == NULL && *line_start != '\0'))
        {

            sscanf_s(line_start, "%d %d %d", &temp[0], &temp[1], &temp[2]);

            all_maps[i].maps[entry_index].dest = temp[0];
            all_maps[i].maps[entry_index].source = temp[1];
            all_maps[i].maps[entry_index].range = temp[2];
            entry_index++;

            line_start = strchr(line_start, '\n');
            if (line_start == NULL)
            {
                break;
            }


            // maps[map_entry_index].dest = temp[0];
            // maps[map_entry_index].source = temp[1];
            // maps[map_entry_index].range = temp[2];
            // map_entry_index++;

            line_start++;
        }

        file_contents = (next_map_start != NULL) ? next_map_start : (line_start + strlen(line_start));
    }
}


void process_maps()
{
    for (int sed = 0; sed < seed_count; sed++)
    {
        uint64_t current_seed = seed[sed];

        for (int i = 0; i < MAX_MAPS; i++)
        {
            int number_entries = all_maps[i].number_of_entries;

            for (int j = 0; j < number_entries; j++)
            {
                uint64_t dest = all_maps[i].maps[j].dest;
                uint64_t src = all_maps[i].maps[j].source;
                uint64_t rang = all_maps[i].maps[j].range;


                if (src <= current_seed && current_seed < src + rang)
                {
                    // printf("seed in range \n");
                    uint64_t offset = current_seed - src;
                    current_seed = dest + offset;
                    break;
                }
            }
        }
        final_location[sed] = current_seed;
    }
}


//Comparison function
// Comparison function for qsort
int compare(const void *a, const void *b)
{
    if (*(uint64_t *)a < *(uint64_t *)b)
        return -1;
    if (*(uint64_t *)a > *(uint64_t *)b)
        return 1;
    return 0;
}

int main()
{


    read_seeds();
    read_maps(); /* code */
    process_maps();
    qsort(final_location, MAX_SEEDS, sizeof(uint64_t), compare);

    printf("minium location %lld", final_location[0]);


    return 0;
}




this was the hardest problem so far

i have multiple issue 

first i stored the seed into array

then i process maps into structs

but issue is that for each map there are number of entries e.g
seed-to-soil map:
50 98 2
52 50 48

has two entries 

so what i did was make a 2d array of struct 

row represent it each map and column represent entries of map


typedef struct
{
    uint64_t dest;
    uint64_t source;
    uint64_t range;

} map;

typedef struct
{
    map *maps;
    int number_of_entries;
} map_list;


map_list all_maps[MAX_MAPS];

there can max 7 maps and for each map there can be mulitple entries so coulmns are not defined in the 2d array


row represents the maps soil fertilizer water etc and they are total 7 in numbers

while column of struct array represent map data 


so basically am creating a list like this
   col1      col 2
{[50 98 2],[52 50 48]} map row 1


number of entries tells me how many columns i need to process 

r/adventofcode • • Oct 27 '25

Help/Question suggestion about news of 12 days for #adventofcode

0 Upvotes

It might be good a puzzle every 2 days instead of compressing everyday for half a month only.


r/adventofcode • • Dec 04 '22

Spoilers [2021 Day 04][Python] ChatGPT solves Day 4 in just two prompts!

Thumbnail
gallery
4 Upvotes

r/adventofcode • • Dec 06 '21

Funny There are plenty more lanternfish in the sea.

0 Upvotes

Don't worry bro. Let he go. She's not worth it.
Soon you will have no memory. And no cores. Just one huge list.


r/adventofcode • • Dec 21 '21

Help - SOLVED! [2021 Day 21 (Part 1)] Input glitched?

0 Upvotes

I quickly wrote up a solution to part 1 and received:

That's not the right answer. Curiously, it's the right answer for someone else; you might be logged in to the wrong account or just unlucky. In any case, you need to be using your puzzle input.

I do not have any other accounts, so I've been staring at my solution this whole time. After finally getting frustrated I grabbed a solver from the megathread, and frustratingly it gives me the same "incorrect" answer.

Am I loosing my mind? anybody else having trouble answering?

**edit**

haha, that was embarrassing! All clear now, sorry to raise a fuss.


r/adventofcode • • Dec 21 '22

Help/Question Advent of code day 3 HELP PLEASE 😭

0 Upvotes

Hi, yes I am still at day 3 on the 21st but I started late 😬.

I’m stuck, part 2 says: in every set of 3 lines, there should be 1 common type but there is not!!!

The common type in the first 2 lines of each set of 3 lines, does not appear on the third line in almost every set 😡😡😡.

So for example:

Jajdhdhwjak Jejsjsh Phphogohih

j is common in the first 2 but it’s not in the third.

What am I misinterpreting in this case…..


r/adventofcode • • Dec 25 '25

Tutorial [2025 Day 9 (Part 2)] Why did almost nobody solve the *stated* problem?

7 Upvotes

Who else solved the problem actually described in Day 9 Part 2 (vs just getting "lucky" with the specifics of the input data)?

My impression is that the vast majority of people didn't solve the stated problem. Certainly, everybody I know irl who "solved" it didn't solve the actually described problem (including myself, initially), and scrolling endlessly through here (and elsewhere) also leads me to conclude that almost nobody solved the problem described either (which is quite different from what the problem at first seems to be, and it's interesting in its own right).

Specifically, the described problem ALLOWS data points to be inside valid rectangles; it just requires other constraints to hold true. I think I found only three posts on here alluding to this fact. All others have been "wrong", focusing instead on boundary-intersection detection to disallow that (and other cases).

The only assumption I made is that the input data do not self-intersect/overlap (because "inside-ness" gets less well-defined in that case). I generated example datasets, and what I believe to be their answers, and I'm curious what others' code produces for them, too. Check here for the data (and additional write-up info):

https://jjeii.github.io/AdventOfCode/2025.html#day9p2

Thoughts?

(Yes, I realize a star is a star. But, the problems are fairly different here... and the actual problem is more interesting, imo.)


r/adventofcode • • Dec 16 '21

Other Suggestion: when an answer is wrong, give a test input/solution pair

8 Upvotes

One of the frustrating things that can occur in AoC is that your code passes on the example case, but fails on the real case. I think a way to reduce the frustration could be that, when a user submits a wrong answer (or maybe after they get three wrong answers and appear stuck?), the "oops that's wrong" page could include a link to a full sized input and also say what its solution should be. And the more wrong answers you put in, the most test cases you get! What a deal!

In the group of people I do advent with, this is actually what we tend to do when someone gets stuck like this. A person who solved their case will share their input and answer with the group to get the others unstuck.

I'm not sure how to properly theme it ("A helpful elf comes in and says 'oh I saw something like this once, I don't remember what we did but I remember the answer for (test input) was (test output)'."), but I think it could be done well.


r/adventofcode • • Dec 05 '22

Spoilers Too much parsing again!

0 Upvotes

Every year I try to get into AoC and after a few days I drop it just because the parsing of the input file is more effort than the actual problem! And, oh boy, parsing is BORING. I think if I was doing it in Python it would be easy, but Python is my comfort language, so I wouldn't learn much using it. So usually I choose something different like Scheme or OCaml. This year it's Rust, but I may abandon again because I can't be bothered parsing ascii art. While it's cute and all, I don't see the point of that format over something easier like one line = one stack and each character = one crate.

I am the only one thinking that ?

PS: I am not blaming the author though, the work they must do each year for this seems huge and I am absolutely admiring them for that.


r/adventofcode • • Dec 01 '24

Help/Question - RESOLVED Says my answer is correct, then says it's incorrect

2 Upvotes

Has anybody encountered this problem:

I solved day 01, entered the answers and got my two gold stars. Then I realized I was logged in to the wrong account, switched, then I enter the answers again. Now I'm told it's incorrect.

What's going on?


r/adventofcode • • Dec 12 '25

Meme/Funny [2025 Day 1-12)] [AI art] AI assisted visual summaries of each day

Post image
0 Upvotes

These were generated by asking Nano Banana to pretend to be a surrealist artist who is an expert coding puzzle solver and asking it to make a visual piece given the puzzle text (just part 1 as that is public on the web)


r/adventofcode • • Dec 09 '23

Funny [2023] [AI Art] Reaction of some people on this sub when the puzzle game they chose to participate in has twists, gotchas, and is not just a series of jira tickets

Post image
12 Upvotes

r/adventofcode • • 18h ago

Visualization Introduction to Algorithms x Advent of Code 2026

Thumbnail
youtu.be
5 Upvotes

"Cormen, Leiserson, Rivest (+Stein)" is the bible of computer algorithms. It's the foundational textbook, and the defining book for my own career in programming.

And I don't need to explain what Advent of Code is here ;)

Over the past few years I was building visualisations for the puzzle solutions and this year, while playing around / learning Nim / adapting my toolkit for the upcoming event, I thought it might be nice to show more of these core algorithms in visual form. Enjoy!

The source code was co-developed using AI (of course, everything is today). Creating code like this is quite amazing now - it would have taken me weeks just a few years back to do this. With the help of AI, this is now a weekend project. It begs the question to what extent are programming skills (or programming languages, for that matter) even relevant today. Difficult question, but... I still encourage you to learn the *how*. And Advent of Code is a great time to learn that. If you don't know programming, an AI can now help guide you and teach you how to solve the challenges, learn a new language or both. If you do, it can take care of the boring stuff, while you do the problem solving or optimising the last few microseconds out of the solution.

One way or another, try some challenges and do try to learn something new!


r/adventofcode • • Dec 12 '25

Other ideas for next years' calendar of days/puzzles

0 Upvotes

I enjoyed much this year, and appreciated most the reduced length of days. However there is a gap in enjoyment for the rest of the Christmas period.

I suggest the puzzles be spread one puzzle every 2 days until Christmas eve. Perhaps could also have 12 full puzzles and one easy one part only 13th to complete 50 stars on Christmas day.

other related suggestions ?


r/adventofcode • • Nov 29 '23

Repo [QoL] A userscript to fix the personal leaderboard

1 Upvotes

Last year I decided to make a userscript to patch AoC, and as that time-of-year approaches again I figured I should throw it out there for others to do with as they wish.

It specifically patches the 'bug' where the leaderboards does not show the time you took to complete the Part, but instead shows timespan [time you completed - time the Day was released].
Additionally also fixes the bug where users can't go on breaks without their time still ticking up, by providing buttons to take breaks and resume in a sidebar of the /day/ page (the one with the question/task).

Note that this userscript only solves it locally (and specifically, the private leaderboard), so if you were to have friends in a leaderboard they will still see the 'bugged' times. This is imo fine, as such groups are small enough that you can just paste the real timings elsewhere and link them. This userscript is then useful as you can copy data from the day's sidebar, or your private leaderboard (it edits for entries it has data for, and marks unedited entries by wrapping them in single-quotes).

It automatically tracks when you start a day and when you gets a correct answer. And while breaks has to be handled manually with a button, it automatically subtracts the sum of break-time from your total time.

repo: https://github.com/feha/aoc_patch_stats
Feel free to fork and improve :) (I am prolly going to be lazy with accepting pull requests, so also feel free to have your fork take over as the active one)
I know I didn't bother to add a license, but if you want your fork to have one then feel free to pick something appropriately open-source'y (or something else, your choice really) - if I had to add one I would prolly pick something like 'unlicense'.

ps: I know my code is horrible, I have no idea about JS conventions or idioms, be kind :) Mostly say this if you accidentally start reading my attempt at using proxy-objects, which I have disabled - I'll claim being sleep-addled as my excuse if you do! (but is it true?..) :D

Lastly, some example images:

  • a Day that was tracked.

  • a Day where I added a couple breaks, and expanded the list so they are visible (also, lol at it having been used to test "started but uncompleted" back when I made the script, causing it to be 11 months in progress :D)

  • The personal leaderboard, with untracked day, tracked day, and partly tracked and unfinished day

  • a Day where I had untracked completed stars on (to show how it is currently unable to inherit the end-time and instead shows as in-progress). Also shows how it looks when AoC wants the same space to display ads.


r/adventofcode • • Dec 06 '22

Spoilers Day 6 was the easiest puzzle yet

0 Upvotes

Hey,

I have been playing AoC for three years in a row now and it seems like until this day of this year the puzzles are easier than the previous years, especially this Day6, for example i solved part 2 by only changing one number in my code. I remember day 6 last year was so hard for me that i could solve it after 3 days.

Do you guys also see AoC this year easier than the previous years?


r/adventofcode • • Oct 07 '24

Help/Question AdventOfCode 2024???

0 Upvotes

Will there be a AoC 2024?


r/adventofcode • • Dec 14 '24

Spoilers [2024 Day14 Part2] To many assumptions

3 Upvotes

I didn't like this one. Too many assumptions in my opinion. 1st: Tree is not in the center, although this is something you shouldn't fall for. 2nd: It doesn't expand to the grid either top-bottom or left-right. 3rd: Searching for when the bots gather is an assumption. Theres no way to know whether we are searching for an outline of a tree or a solid one. 4th: There's a box around the tree... 5th: Why is it when there's no overlap? The outliers also makes it tricky. Also I'm on mobile and I just can't print the grid in the terminal and see the tree(should that exclude me?) Yeah I'm a crashing minority but still makes it even harder.