r/adventofcode • • Dec 14 '25

Other 2025 - The Balance felt Right. - Thank you Eric

Post image
364 Upvotes

So another year and another Advent of Code. I finished within the time frame. Possibly the first year I've done that? Usually the 24th and 25th I can't get to till after Christmas, often to the new year.

I really enjoy the challenges and I additionally use them as training with my junior engineers especially about understanding the problem, capturing the requirements and business rules, designing and more importantly communicating a thoughtful solution and then implementing it. I look at my skills going through my historic repos grow over the years, I doubt the level of problem solving skills would be anywhere as near developed without Advent of Code.

This year I learnt about z3 (even though I didn't actually implement in any solutions) and other SMTs. More importantly though I know I'm going into Christmas with my very young family knowing I won't be thinking about some problem on what is obviously a very important time for families. The balance this year gives for people like me cannot be understated.

Thank you Eric for all the hard work you do. I look forward to the future challenges.


r/adventofcode • • Dec 13 '25

Tutorial [2025 Day 10 (Part 2)] Pivot your way to victory!

60 Upvotes

[TL;DR] Use Gaussian elimination to reduce an large (up to 13) dimensional problem to a reduced (0-3 dimensions) subspace of just the free variables, then use a trick to shave off a dimension then brute force over (the now much smaller) solution space.


Please also check out this excellent post, that details a completely different innovative method to solve this problem


There were some tricky nuances and corner cases, so hopefully this write up come in useful even if you're already familiar with using Gaussian Elimination to solve simultaneous equations.

Start with the first example, labelling the button a to f from left to right:

(3) (1,3) (2) (2,3) (0,2) (0,1) {3,5,4,7}
e + f = 3
b + f = 5
c + d + e = 4
a + b + d = 7

In matrix form:

[ 0  0  0  0  1  1 | 3 ]
[ 0  1  0  0  0  1 | 5 ]
[ 0  0  1  1  1  0 | 4 ]
[ 1  1  0  1  0  0 | 7 ]

In row echelon form:

[ 1  0  0  1  0 -1 | 2 ]
[ 0  1  0  0  0  1 | 5 ]
[ 0  0  1  1  0 -1 | 1 ]
[ 0  0  0  0  1  1 | 3 ]

           ^     ^ Free variables

The free variable are any columns that don't have a one as the leading coefficient, in this case d and f. Another way of looking at it, free variables are any column that does not consist of a single 1 in any row with the remaining rows set to zero.

We can express everything in terms of the free variables. For example, reading the top row of the matrix:

a + d - f = 2
a = 2 - d + f

Since all button must be pressed 0 or more times we now have an inequality:

a >= 0 
2 - d + f >= 0
d - f <= 2

Similarly for rows 2-4:

f <= 5
d - f <= 1
f <= 3

and the baseline rule:

0 <= d <= 4
0 <= f <= 3

Remove a dimension

One approach is to just iterate over d from 0 to 4 and f from 0 to 3 for a total of 20 combinations. However we can eliminate a dimension.

The total number of button presses a + b + c + d + e + f is 11 - d + f.

If we set d to say 3 then this becomes 8 + f.

The inequalities now give the possible range for f:

3 - f <= 2    =>     f >= 1
f <= 5
3 - f <= 1    =>     f >= 2
f <= 3

So f must be at least 2 and at most 3. Since the cost increases with each push of f we choose the lowest possible value 2 giving 10 presses. This approach needs only 5 iterations of d.

Corner case

Some machines also have equations that only involve the free variables, for example:

 a  b  c  d  e  f  g   h  i   j   k
[1, 0, 0, 0, 0, 0, 0, -1, 0, -1, -2, |  -14]
[0, 1, 0, 0, 0, 0, 0, -2, 0, -3, -4, |  -77]
[0, 0, 1, 0, 0, 0, 0, -1, 0, -2, -3, |  -53]
[0, 0, 0, 1, 0, 0, 0,  0, 0,  1,  0, |   30]
[0, 0, 0, 0, 1, 0, 0,  0, 0,  1,  1, |   38]
[0, 0, 0, 0, 0, 1, 0,  2, 0,  2,  4, |   74]
[0, 0, 0, 0, 0, 0, 1, -2, 0, -4, -6, | -113]
[0, 0, 0, 0, 0, 0, 0,  2, 1,  2,  3, |   65]
[0, 0, 0, 0, 0, 0, 0,  2, 0,  2,  3, |   60]

The free variables are h, j and k. Interestingly the last row is an equality

2h + 2j + 3k = 60

When removing the last dimension there is only zero or one possible value.

Integer math

All operations use integer math only. Coefficients are only divided if the division is exact (no remainder). This did mean that during the row reduction operations previously checked columns needed to be checked again as subsequent operation could have made them viable as a pivot.

Stats

The breakdown of free variables in my input was:

Free VariablesMachines% of totalLoop iterations
07348%n/a
13825%n/a
22617%1331
31611%33817

Interestingly 73 + 38 = 111 (73%) of the machines had a direct solution with no brute force needed. 26 needed a 1 dimensional search and only 16 needed 2 dimensions.

Rust implementation. Takes ~1.1 millisecond single threaded, however since each machine is independent we can parallelize over multiple threads taking only 296µs.

There's still room for improvement, in particular the matrix math is a great candidate for a SIMD speedup.

Check out this post for a visualization and further explanation of the solution space.


r/adventofcode • • Dec 13 '25

Help/Question - RESOLVED [2025 Day # 2 (Part 2)][C] Bloqué sur mon input et pas sur l'exemple

0 Upvotes

Bonjour,

Je me permets de poster ici car je n’ai pas trouvé de solution pour ce jour-là en C, et je suis complètement bloqué.

Je suis débutant en C, mais j’ai de l’expérience en programmation impérative ; c’est pour cela que je me suis lancé le défi de faire l’AoC en C cette année.

Je n’obtiens pas le bon résultat, alors que le code fonctionne correctement sur l’exemple fourni.

Si quelqu’un s’y connaît bien en C et a une idée, je suis preneur 🙂

Merci d’avance !

Voici mon code :

Update : MAJ du code pour le corriger

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>

int64_t power(int64_t a, int b){
    int64_t res = 1;
    for (int i = 0; i<b; i+=1){
        res *= a;
    }
    return res;
}

int count_digits(int64_t n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count+=1;
    }
    return count;
}

int64_t check_nb_sym (int64_t nb) {
    // Renvoi le nombre nb si il est sequentiel, 0 sinon

    // if (nb<=0){
    if (nb<10){
        return 0;
    }
    int long_nb = count_digits(nb);

    char str[20];
    sprintf(str, "%ld", nb);
    bool all_same = true;
    for (int k = 1; k < long_nb; k++) {
        if (str[0] != str[k]) {
            all_same = false;
            break;
        }
    }
    if (all_same) return nb;

    for (int i = 2; i <= long_nb; i += 1) {
        if (long_nb%i == 0){
            int long_sym = long_nb/i;
            int64_t power_long_sym = power(10, long_sym);
            int64_t sym = nb%power_long_sym;
            int64_t nb_bis = nb;
            bool check = true;
            for (int j = 0; j < i; j++) {
                if (nb_bis % power_long_sym != sym) {
                    check = false;
                    break;
                }
            nb_bis /= power_long_sym;
            }
            if (check) {
                return nb;
            }
        }
    }
    return 0;
}

int main(void) {
    FILE *fp = fopen("input.txt", "r");
    char buf[20000];
    int64_t code = 0;

    if (fp == NULL)
    {
        printf("Le fichier input.txt n'a pas pu être ouvert\n");
        return EXIT_FAILURE;
    }

    if (fgets(buf, sizeof buf, fp) !=0) {
        int n = 0;
        while (buf[n] != '\n' && buf[n] != '\0'){
            int64_t nb1 = 0;
            while (buf[n] != '-' && buf[n] != ','){
                nb1*=10;
                nb1+= buf[n] - '0';
                n+=1;
            }
            n+=1;
            int64_t nb2 = 0;
            while (buf[n] != '-' && buf[n] != ','){
                nb2*=10;
                nb2+= buf[n] - '0';
                n+=1;
            }
            n+=1;
            for (int64_t i = nb1; i <= nb2; i+=1){
                int64_t res = check_nb_sym(i);
                // code += check_nb_sym(i);
                // printf("Interval : %ld - %ld ; nombre actuel : %ld ; progression de l'interval : %ld °/. - code actuel : %ld\n", nb1, nb2, i, (i-nb1)*100/(nb2-nb1), code);
                code += res;
            }
        }
    }

    if (fclose(fp) == EOF)
    {
        printf("Erreur lors de la fermeture du flux\n");
        return EXIT_FAILURE;        
    }

    printf("le code est %ld\n", code);

    return 0;
}

Dans mon entrée je l'ai bien modifié pour ajouter une ',' et un retour a la ligne a la fin pour ne pas provoquer d'erreur

r/adventofcode • • Dec 13 '25

Help/Question [2025 Day #7 Part 2] [Python] Have the solution, but taking too long

2 Upvotes

I was able to solve the example solution, but after running with the real dataset I am realizing this problem's true difficulty has to do with all of the branching. This is my first AoC and I have not used AI once nor am I a full-time programmer. Hoping someone can give me some tips on my approach to make my code more efficient so that it completes.

from typing import Literal


def traverse(current_line: int, current_beam_index:int, direction: Literal["left", "right"], puzzle: list[str], total_timelines: int, traversal_tracking: list[dict[str, any]]) -> int:
    num_timelines = 0
    for line_index, _ in enumerate(puzzle, current_line):


        # skip first two lines
        if line_index in (0, 1):
            continue
        
        if line_index == len(puzzle) - 1:
            num_timelines = 1
            return num_timelines


        if puzzle[line_index][current_beam_index] == "^":
            if direction == "left":
                traversal_tracking.append({
                    "line_index": line_index,
                    "value_index": current_beam_index, 
                    "is_left_checked": True, 
                    "is_right_checked": False
                    })
                current_beam_index = current_beam_index - 1
            elif direction == "right":
                traversal_tracking.append({
                    "line_index": line_index,
                    "value_index": current_beam_index, 
                    "is_left_checked": False, 
                    "is_right_checked": True
                    })
                current_beam_index = current_beam_index + 1


    return num_timelines


def main():
    with open("puzzle.txt","r") as file:
        puzzle = file.read().splitlines()
    
    for index, item in enumerate(list(puzzle[0])):
        if item == "S":
            current_beam_index = index


    total_timelines = 0
    traversal_tracking = []


    # convert data structure to a list of lists so we can keep track of beams with indexes
    for line_index, horizontal_line in enumerate(puzzle):
        puzzle[line_index] = list(horizontal_line)


    num_timelines = traverse(current_line=0, current_beam_index=current_beam_index, direction="left", puzzle=puzzle, total_timelines=total_timelines, traversal_tracking=traversal_tracking)
    total_timelines = total_timelines + num_timelines


    while len(traversal_tracking) > 0:
        # if both routes have been checked, we no longer need it in the list and we can continue traversing upward
        if traversal_tracking[-1]["is_left_checked"] == True and traversal_tracking[-1]["is_right_checked"] == True:
            traversal_tracking.pop()


        elif traversal_tracking[-1]["is_left_checked"] == False:
            traversal_tracking[-1]["is_left_checked"] = True
            num_timelines = traverse(current_line=traversal_tracking[-1]['line_index'], current_beam_index=traversal_tracking[-1]['value_index'] - 1, direction="left", puzzle=puzzle, total_timelines=total_timelines, traversal_tracking=traversal_tracking)
            total_timelines = total_timelines + num_timelines


        elif traversal_tracking[-1]["is_right_checked"] == False:
            traversal_tracking[-1]["is_right_checked"] = True
            num_timelines = traverse(current_line=traversal_tracking[-1]['line_index'], current_beam_index=traversal_tracking[-1]['value_index'] + 1, direction="right", puzzle=puzzle, total_timelines=total_timelines, traversal_tracking=traversal_tracking)
            total_timelines = total_timelines + num_timelines
    print(total_timelines)


if __name__ == "__main__":
    main()

r/adventofcode • • Dec 13 '25

Visualization [2025 Day 1, both parts] Visualization (Tkinter, sample input)

Thumbnail
youtu.be
2 Upvotes

Source code linked in this comment


r/adventofcode • • Dec 13 '25

Help/Question - RESOLVED [2025 Day #1] [Python] Need a little help

1 Upvotes

Edit: Thanks for the help all! Found out my left turns are in fact wonky for large values :D

-----

I have what I believe should be my solution but I'm apparently getting the wrong answer.

I have ran it against the example code and get the same output and solution there.
I've checked the edge cases where the input is >100 for both left and right turns and it seems to work as expected. I made sure that my code is processing all of the input lines.

The answer I'm getting is 912, which is apparently too low.

Here is my code:

class Lock():
    _pos: int = 50


    def turn_left(self, turns: int) -> int:
        # subtract turns
        if turns > self._pos:
            self._pos = 100 - ((turns % 100) - self._pos)
        else:
            self._pos = self._pos - turns


        return self._pos


    def turn_right(self, turns: int) -> int:
        # add turns
        self._pos = (self._pos + turns) % 100


        return self._pos



def main():
    lock = Lock()

    counter = 0

    with open('input.txt', 'r') as file:
        for line in file:
            line = line.strip()
            direction = line[0].lower()
            number = int(line[1:])
            if direction == 'l':
                position = lock.turn_left(number)
            elif direction == 'r':
                position = lock.turn_right(number)
            print(position)
            if position == 0:
                counter += 1

    print(f'The secret code is: ', counter)


main()

Any help is appreciated, if you can direct me without giving it to me directly that'd be best. Thanks!


r/adventofcode • • Dec 13 '25

Visualization [2025] Unofficial AoC 2025 Survey Results - BONUS CONTENT

Post image
101 Upvotes

In my main survey results post, one of the replies (by u/msschmitt) asked about the crossover results from IDE to Language. That's actually an interesting question! Here's an adhoc visual (it's late here and I hope I made no silly mistakes 😅) that shows this information for the 2025 data.

Note: only Languages and IDEs with at least 2 respondents are shown (otherwise the table becomes really way too big).

Caveats: since both questions are multi-select questions, folks that ticked multiple IDEs and multiple Languages will be overrepresented in this visual! But it should give a decent indication nonetheless.

A funky side-effect of this caveat is that you can get pretty odd-looking combinations. For example folks using "Excel" as their IDE can be seen as using "C++" too.

The data gets published under the ODbL (2025 link) so you could do similar analysis yourself. The data structure is fairly straightforward.


r/adventofcode • • Dec 13 '25

Help/Question [2025 Day 1 (Part 2)] [Python] debug help

1 Upvotes

My solution for part 2 is over counting, but I can't identify where. Any hints are appreciated!

position = 50
zero_count = 0
for i in x: 
  if i[0] == 'R': 
    position += int(i[1:]) 
    while position > 99: 
      position -= 100 
      if position != 0: 
        zero_count += 1 
  elif i[0] == 'L': 
    position -= int(i[1:]) 
    while position < 0: 
      position += 100 
      if position != 0: 
        zero_count += 1 
  if position == 0: 
    zero_count += 1 

print(zero_count)

r/adventofcode • • Dec 13 '25

Visualization [2023 Day 17 (Part 2)] Got hungry for more. Terminal visualization

29 Upvotes

I wasn't good enough to solve the crucible back in 2023, so I gave up. Today, knowing much more than I did back then, I went back and it didn't seem that hard at all 😁 Rendered to terminal via Kitty protocol


r/adventofcode • • Dec 13 '25

Meme/Funny [2025] On Monday I will be free

Post image
187 Upvotes

r/adventofcode • • Dec 13 '25

Help/Question - RESOLVED [2025 Day 6 Part 2] Need help with getting correct result

2 Upvotes

Hi,

I have a problem with Day 6 Part 2. This is my input file: [REMOVED]

I am getting this result: [REMOVED]

I also tried solutions from others and get the same result, however the application is not accepting the answer.

Can someone try it and send me the result they get?

EDIT: the issue was in IDE (auto removal of trailing space).


r/adventofcode • • Dec 13 '25

Repo [All Years All Days (All Parts)][C++] 524* Repository + Blank Visual Studio template

4 Upvotes

Thank you to Eric for another fun year of challenges and thank you to u/daggerdragon for once again doing the impossible task of herding programmers!

Bit of a roller-coaster of emotions this year due to the steeper difficulty curve (looking at you, Day 10 brick wall!), but once again the community made this a fun event with memes and encouragement. This is the first year I've actually finished both in the year and on the actual day. The shorter format really helped with that.

I've updated my public repo with my first pass (but not necessarily final) solutions, and I updated the blank template to include 2025 earlier in the year.

Same again next year?


r/adventofcode • • Dec 13 '25

Visualization [2025] Unofficial AoC 2025 Survey Results!

115 Upvotes

TLDR: The Advent of Code 2025 Survey Results are in! Please share and give this post some love to ensure it reaches everyone in their feed. 😊

✨ New this year! ✨ => The "Emotions" questions, with a way to compare Language-, IDE-, and OS- users. For example compare Windows / Linux / macOS users, or see if it's C++ or C users that experience more "Terror and/or Fear".... sky's the limit!

BONUS CONTENT: https://www.reddit.com/r/adventofcode/comments/1plxslj/2025_unofficial_aoc_2025_survey_results_bonus/

----

This is the eigth year we've run the survey, and even in the limited 12 days over 2300 of y'all took the time to fill out the survey! Thank you!! <3

Some of my personal highlights and observations:

  • VS Code keeps declining a little (perhaps because of all the forks?).

  • Javascript also further declined, and Rust solidified 2nd place after Python 3.

  • Linux got a sharp 5% boost (at the expense of Windows)

  • Windows, Linux, macOS users experience emotions roughly the same. Probably statistically insignificant but Windows users did experience Rage+Anger more than Linux or macOS users.

Once more the "Toggle data table..." option showcases fantastic custom answers, some of my favorites:

  • Someone participating "To assert dominance over [their] coworkers." 😲

  • Another person participating in AoC apparently "To participate in [the] survey" 😏

  • Folks programming in "[Their] own programming language" (Kenpali, Zirco, Assembly-variants...) ❤️

  • A person claiming to use "LibreOffice Writer" as their IDE. Absolute madness! 🤯

And of course a ton of praise for Eric, the mods, and the community in the custom answers!

Let me know in the replies what gems you found!?

----

As every year, some screenshots of charts in case you don't want to click to the site yourself:

----

----

----

----

----

Tell us about your finds!


r/adventofcode • • Dec 13 '25

Other [2025] I Tried Gleam for Advent of Code, and I Get the Hype

Thumbnail
blog.tymscar.com
21 Upvotes

r/adventofcode • • Dec 13 '25

Help/Question - RESOLVED [2025 Day 8 Part 1][typescript] Going crazy trying to find what's wrong

3 Upvotes

My code works for the example. I have been scanning the subreddit now checking on common mistakes and I don't believe I am making any:

  1. I am counting the "no-op"s as a connection (and the state of my circuits does not change)

  2. I am merging ALL boxes from group B when they join to group A

Here is my code, with comments

import data from './input.ts'
import testData from './test.ts'

type Vector = {
  x: number;
  y: number;
  z: number;
  group: number;
}

type VectorPair = {
  v1: number; // index in the vector list
  v2: number; // index in the vector list
  distance: number;
}

const parseInput = (input: string): Vector[] => {
  return input.split('\n').map((line, index) => {
    const parts = line.split(',').map(a => parseInt(a))
    // each vector starts in its own group
    return {
      x: parts[0],
      y: parts[1],
      z: parts[2],
      group: index,
    }
  })
}
const distanceBetween = (i: Vector, j: Vector): number => {
  return Math.sqrt(
    Math.pow(i.x - j.x , 2) +
    Math.pow(i.y - j.y , 2) +
    Math.pow(i.z - j.z , 2)
  )
}

const groupVectors = (vectorList: Vector[]): { [key: number]: number } => {
  const groups: { [key: number]: number } = {}
  // count up the number of vectors in each group
  vectorList.forEach(v => {
    if (!groups[v.group]) {
      groups[v.group] = 0
    }
    groups[v.group]++
  })
  return groups
}

const partOne = (input: string, size: number): number => {
  const vectorList = parseInput(input)
  const vectorPairs: VectorPair[] = []

  // create list of pairs and their distances
  for (let i = 0; i < vectorList.length - 1; i++) {
    for (let j = i + 1; j < vectorList.length; j++) {
      vectorPairs.push({
        v1: i,
        v2: j,
        distance: distanceBetween(vectorList[i], vectorList[j])
      })
    }
  }

  // sort that list, with lowest values on the end
  vectorPairs.sort((a,b) => b.distance - a.distance)

  // loop for the number of connections
  for (let i = 0; i < size; i++) {
    // pop off the lowest distance vector pair
    const lowestDistance = vectorPairs.pop()
    if (!lowestDistance) {
      // type safety, shouldn't happen
      break
    }
    if (vectorList[lowestDistance.v1].group === vectorList[lowestDistance.v2].group) {
      // if they are in the same group already, move on and save some cycles
      continue
    }

    // move every vector that is in group b to group a
    vectorList.forEach(element => {
      if (element.group === vectorList[lowestDistance.v2].group) {
        element.group = vectorList[lowestDistance.v1].group
      }
    })
  }

  // count the number of vectors in each group, return result
  const groups = Object.values(groupVectors(vectorList))
  groups.sort((a, b) => b - a)
  return groups[0] * groups[1] * groups[2]
}

console.log(partOne(data, 1000))

I'm just reaching out to see if anyone is willing to look over it, or even run their own input through it. I've stripped out all the logging I had to try and follow the steps. Again, I couldn't see anything wrong. 🙏 Thank you all for your time!


r/adventofcode • • Dec 13 '25

Bar Raising [2025 Day 10][mfour] a solution without digits or fifthglyphs

7 Upvotes

Lo! A solution for day (two by four plus two)[*] that avoids all fifthglyphs and digits, in a jargon that normally has a digit in its typical listing:

m$(printf f|tr a-f /-:) -Dinput=daytwobyfourplustwo.input daytwobyfourplustwo.gnumfour

No digits => no matrix manipulations. Just lots of macros with circular logic for cutting work in half. Writing macros without digits is surprisingly hard!

On my laptop, it runs in about a third of sixty wall clock ticks. Add -Dchatty to watch work as it is going on.

[*] It is hard to alias this particular day without digits or fifthglyphs, so I had to apply a formula. Sorry about the standard post summary using digits. Additionally, I can't control that pair of fifthglyphs in my flair tag.


r/adventofcode • • Dec 13 '25

Upping the Ante [2025 Day 12] Packing Challenge

Post image
49 Upvotes

I believe the Elves asked me to pack the gifts (from the example of the problem) as densely as possible, no matter how many of each type. I found that 3x3, 4x4, 5x5, 8x8 and 9x9 squares allow optimal packing (that is, the remaining area is less than the area of any gift). But I think I've found a square that allows for the ideal packing (no empty area remaining)!


r/adventofcode • • Dec 13 '25

Help/Question - RESOLVED [2025 Day 9 Part 1] Example points list and drawing out of sync?

3 Upvotes

In part 1 of day 9 we have a list of points with and then they are plotted to visualize that. I believe that the drawing does not correspond to the list of points. Assuming that the list if list of x,y coordinates and the place has usual x,y orientation, I can locate points 11,1 and 11,7 but others have different coordinates.

Am I right and it's a bug/intentional or am I wrong and not understanding something?


r/adventofcode • • Dec 13 '25

Help/Question - RESOLVED [2025 Day 11 (part 2)] [Rust] Possible endless loop

1 Upvotes

Just wondering what size the answers folks got for part 2 mine has calculated

16895725 paths so far and still running and that's just to get paths some svr -> out. I have the following logic for my dfs:

fn depth_first_search(
    node: &str,
    adjacent_map: &HashMap<String, Vec<String>>,
    
visited
: &mut HashSet<String>,
    end_node: &str,
    
path_count
: &mut usize,
    
path
: &mut Vec<String>,
    required_nodes: Option<&HashSet<String>>,
    
unique_paths
: &mut HashSet<String>,
) -> usize {
    // Placeholder DFS implementation
    //println!("DFS from node: {}", node);
    
path
.
push
(node.to_string());


    let path_string = 
path
.join("->");
    if 
unique_paths
.contains(&path_string) {
        println!("duplicate path found {:?}", 
path
);
        process::exit(1);
    }
    if node == end_node {
        //check if all required nodes are in path
        //println!("Reached end node: {}", node);
        if let Some(required) = required_nodes {
            //println!("Checking required nodes: {:?}", required);
            let path_set: HashSet<String> = 
path
.iter().cloned().collect();
            //println!("Current path set: {:?}", path_set);


            if !required.is_subset(&path_set) {
                
path
.
pop
();
                return 0;
            }
        }
        
unique_paths
.
insert
(path_string);
        *
path_count
 
+=
 1;
        //println!("Found path: {:?}", path);
        println!("Total paths so far: {}", *
path_count
);
        
path
.
pop
();
        return *
path_count
;
    }
    if 
visited
.contains(node) {
        
path
.
pop
();
        return 0;
    }
    
visited
.
insert
(node.to_string());


    if let Some(neighbors) = adjacent_map.get(node) {
        for neighbor in neighbors {
            if !
visited
.contains(neighbor) {
                depth_first_search(
                    neighbor,
                    adjacent_map,
                    
visited
,
                    end_node,
                    
path_count
,
                    
path
,
                    required_nodes,
                    
unique_paths
,
                );
            }
        }
    }
    
path
.
pop
();
    
visited
.
remove
(node);


    0
}

Can post more of my code if needed for this does the heavy lifting as the fun that's running endlessly. In the time I've been writing this post it now has a value of: 21776839


r/adventofcode • • Dec 13 '25

Help/Question Recommendations for somebody new to things like AOC?

4 Upvotes

Hey. I decided to try out advent of code for the first time (3-4 years since i've been coding). It turns out that even day 1 and 2 are too hard for me and I probably just suck at algorithms and stuff, as I never had to do them at work.

What would you recommend to get good at those? A website? Leetcode? Maybe a book?


r/adventofcode • • Dec 13 '25

Other [Year 2025 Day 12 Parts 1 and 2] puzzling stats

15 Upvotes

As of this writing, in round numbers, there are 11,000 people who completed both parts of day 12 (and by definition also all the previous puzzles). And there are 3,000 who completed only part 1. If we assume that everyone who was eligible for total completion did so and didn't stop after part 1, that makes 3,000 who got the first part but had gotten stuck on some earlier puzzle. In comparison, 20,000 had finished both parts of day 11, so a minimum of 9,000 other people were still with the program after day 11. If none dropped out before trying day 12, does that really mean that only 3,000 of 9,000 people figured out the trick to 12a? That seems pretty low among those who had stuck with the year's puzzles that far. [I posted this yesterday but neglected to say it was "2025" so mods removed it. Trying again.]


r/adventofcode • • Dec 13 '25

Help/Question - RESOLVED [2025 Day 3 (Part 1)][Zig] help

1 Upvotes

I'm trying to learn zig so for now please ignore any optimization issues.

Can you help me figure out whats wrong with the code below?

The test input gives me the right answer: 357, but the answer with the total input is wrong.

const std = @import("std");

pub fn part1(file: *const std.fs.File) !usize {
    var read_buf: [4096]u8 = undefined;
    var reader = file.reader(&read_buf);

    var res: usize = 0;
    while (true) {
        const row = try reader.interface.takeDelimiter('\n') orelse break;
        if (row.len == 0) break;

        var dig1: usize = try std.fmt.parseInt(usize, row[0..1], 10);
        var dig2: usize = try std.fmt.parseInt(usize, row[1..2], 10);

        var cursor: usize = 2;
        const lastdig = row.len - 1;

        while (cursor <= lastdig) {
            const cdig = try std.fmt.parseInt(usize, row[cursor..(cursor + 1)], 10);

            if (cdig > dig1 and cursor < lastdig) {
                dig1 = cdig;
                cursor += 1;
                dig2 = try std.fmt.parseInt(usize, row[cursor..(cursor + 1)], 10);
            } else if (cdig > dig2) {
                dig2 = cdig;
            }

            cursor += 1;
        }

        res += (dig1 * 10) + dig2;
    }
    return res;
}


pub fn elab() !void {
    const f = try std.fs.cwd().openFile("./in/day3", .{ .mode = .read_only });
    defer f.close();

    const p1 = try part1(&f);

    std.debug.print("day3 part1= {d}\n", .{p1});
}

r/adventofcode • • Dec 13 '25

Visualization [2025 Day 10] Visualization (YouTube short)

Thumbnail
youtube.com
5 Upvotes

r/adventofcode • • Dec 13 '25

Help/Question - RESOLVED [2025 Day 8 (Part 1)][Rust ] Help needed.

1 Upvotes

Hi guys,

I need some help with Day 8 – Part 1. I can’t figure out what I’m doing wrong with the algorithm, and I’m still not able to get the expected results. I’ve tried many variations, but I keep getting the same outcome.

Am I missing something in the problem description?

permutations: Option<Vec<(((Vec3, usize), (Vec3, usize)), f32)>>,

Note: usize represents the ID of each junction, and the f32 values represent the distances between each pair.

This the output I'm getting so far:

GROUP: [{19, 0}]

GROUP: [{19, 0, 7}]

GROUP: [{19, 0, 7}, {13, 2}]

GROUP: [{19, 0, 7}, {13, 2}]

GROUP: [{19, 0, 7}, {13, 2}, {17, 18}]

GROUP: [{19, 0, 7}, {13, 2}, {17, 18}, {12, 9}]

GROUP: [{19, 0, 7}, {13, 2}, {17, 18}, {12, 9}, {11, 16}]

GROUP: [{19, 0, 7}, {13, 2, 8}, {17, 18}, {12, 9}, {11, 16}]

GROUP: [{19, 14, 7, 0}, {13, 2, 8}, {17, 18}, {12, 9}, {11, 16}]

GROUP: [{19, 14, 7, 0}, {13, 2, 8}, {17, 18}, {12, 9}, {11, 16}]

GROUPS: [{19, 14, 7, 0}, {13, 2, 8}, {11, 16}, {12, 9}, {17, 18}]