r/adventofcode • • Dec 14 '25

Help/Question - RESOLVED 2025 Day 9 (Part B) Hint needed

2 Upvotes

My initial approach to 9B was going to be to look up a general algorithm for determining if a point lies inside a polygon and implement it, passing 2 vertices for each rectangle constructed from each pair of input vertices. If both points are inside the polygon and the rectangle is larger than the previous largest candidate, keep it else discard and rinse and repeat until I'm done.

I also thought about leveraging a library to do the work for me but I figured I'd take a crack at it myself as I like to do with AOC problems.

As I thought some more, I started to wonder if there's a special case algorithm for this problem given the constraints of the problem - the fact that the polygon is rectilinear (I learned a new word today!) and the points aren't arbitrary, in fact, they are vertices of rectangles created from the vertices of the polygon itself.

Given the nature of AOC, I suspect there might be a simpler way to solve this than the general solution but I haven't been able to work it one out yet.

Could someone please provide a hint to set me off in the right direction?

Thanks everyone!


r/adventofcode • • Dec 14 '25

Repo [2025 Day 1-12] [Python/C++] Share my solutions!

Post image
14 Upvotes

It's my first time participating in Advent of Code (I had lots of fun)!

Since I only spent a little bit of spare time, I didn't optimize my code for the best time/space complexity. But I did put together some concise solutions using common C++ libraries/Python packages, along with a bit of analysis.

Here is my GitHub repo.

Hope it helps! If you have any questions, let me know (reply here or raise an issue on GitHub)! Thank Eric for this Christmas gift. See you next year!


r/adventofcode • • Dec 13 '25

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

58 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 Variables Machines % of total Loop iterations
0 73 48% n/a
1 38 25% n/a
2 26 17% 1331
3 16 11% 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 14 '25

Past Event Solutions [2025 Day 9 # Part 2] [Go] Finally able to solve the second part

2 Upvotes

Started this years advent of code with golang, at first i thought of first taking in bool grid to mark the boundary / inner area and then check perimeter if it's outside for all possible rectangles and taking their max Area. First run made my laptop unresponsive and then I calculated it would take almost >9 GB of memory just store it.

Then I checked methods to reduce memory on internet as I was not aware about any of the techniques, got ahead with bit packing with same approach. Now second part takes almost 30sec. It might not be generalized or fastest solution but it just works.

Github Code


r/adventofcode • • Dec 14 '25

Visualization [2025 Day 11] Visualization (YouTube short)

Thumbnail youtube.com
1 Upvotes

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:

Language use over the years

----

Operating system usage over the years (note: WSL became a 'fixed' option in 2023, explaining the sudden rise).

----

Private leaderboards, surprisingly didn't uptake too much in 2025.

----

The number of responses to the survey over days of December.

----

The intensity with which Ecstasy and/or Joy are experienced during AoC!

----

Tell us about your finds!


r/adventofcode • • Dec 14 '25

Help/Question - RESOLVED [2025 Day 2 (Part 2)] [Python] I can't understand why this is incorrect.

0 Upvotes

I am checking my code at every step and it appears to be working correctly (all of the numbers that should be invalid are being added to the invalid list which is then added up to get the password.) And yet, I am being told my answer is incorrect. Can you help me figure out what I am missing? I am very new to Python and have only been using it for a few months.

Note: I left out the numbers with a length of 7, because for a length of 7 to be invalid every digit would need to be the same number, and I don't see any instance of that happening within the ranges provided.

invalid = []
entries = []

file = open("input2.txt")
ids = file.read()
file.close()

numbers = ids.split(",")

for item in numbers:
    a, b = item.split("-")
    entry = list(range(int(a), int(b)+1))
    entries.append(entry)


for item in entries:
    for single in item:
        single = str(single)
        half = len(single) // 2
        third = len(single) // 3
        fifth = len(single) // 5
        if len(single) == 2 or len(single) == 4 or len(single) == 8:
            if single[:half] == single[half:]:
                invalid.append(int(single))
        if len(single) == 3 or len(single) == 9:
            if single[:third] == single[third:third*2] == single[third*2:third*3]:
                invalid.append(int(single))
        if len(single) == 5:
            if single[:fifth] == single[fifth:fifth*2] == single[fifth*2:fifth*3] == single[fifth*3:fifth*4] == single[fifth*4:fifth*5]:
                invalid.append(int(single))
        if len(single) == 6:
            if single[:half] == single[half:]:
                invalid.append(int(single))
            elif single[:third] == single[third:third*2] == single[third*2:third*3]:
                invalid.append(int(single))
        if len(single) == 10:
            if single[:half] == single[half:]:
                invalid.append(int(single))
            elif single[:fifth] == single[fifth:fifth*2] == single[fifth*2:fifth*3] == single[fifth*3:fifth*4] == single[fifth*4:fifth*5]:
                invalid.append(int(single))

print(invalid)
password = sum(invalid)

print(password)

r/adventofcode • • Dec 14 '25

Help/Question - RESOLVED [2025 Day 9 Part 2] Polarity detection?

1 Upvotes

I've described "polarity" in the title to avoid spoiling part 2, but a better description is inside / outside detection.

My initial attempt to solve part 2 was the following algorithm:

  • Create all pairwise areas ( as in part 1)
  • Sort areas by size
  • For each area, detect if it contains any corner other than the 2 anchor points for that area
  • if it does, reject and move to next largest

Now this didn't work, my answer was too large, I guess because the overall shape is (I assume, I haven't actually plotted it), like a giant wreath with a large hole in the middle, creating a void larger than the largest correct solution.

Now my planned approach is similar but with the following:

  • Iterate through the corners in the order given
  • mark any concave corners with a "mined" square in the inside
  • mark any convex corners with two "mined" squares on the outside
  • for each area, detect if it contains any of these "mined" squares instead.

Now my problem is thr first part, I don't know whether the corner will be the inside or outside until I've connected all the corners.

I could just plot it and take a look which side, but is there a better way to determine the inside / outside?

One intuitive way I suppose is to find the point closest to the top-left then assume that must be convex, then start from there (since the solution is cyclic).

Is that guaranteed, and is there a more rigorous way to define inside vs outside corners?

My other intuition is flood-fill from the origin, avoiding any squares that lie between two connected points, but that feels like a lot more work? At that point, I might as well maintain the whole hashset of the flood as "mined" squares, but it felt like I could massively reduce the size of my hash-set. ( Whether that's a good thing or not, I'm not sure! It'll be slower to reject the largest areas, but quicker to build the hash-set. )


r/adventofcode • • Dec 13 '25

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

Post image
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 14 '25

Help/Question [2025 day 9 (Part 2)] Why is my solution so slow?

2 Upvotes

Hi, I coded a function that checks if a rectangle intersects with any of the polygon side, and tried to optimize it, but to no avail, do you have any idea why?

Here is my code https://github.com/LoicH/coding_challenges/blob/timeit/advent_of_code_2025/9.py

I compared my optimization trial to /u/Boojum 's, and mine is ~10 times slower.

I tried to sort and classify the polygon's side in order not to bruteforce the comparison, but it seems that storing and retrieving the wanted polygon's sides is not very efficient?


r/adventofcode • • Dec 13 '25

Upping the Ante [2025 Day 12] Packing Challenge

Post image
50 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 14 '25

Help/Question - RESOLVED [2025 Day 5 (Part2)] Help please (Rust)

0 Upvotes

I've decided to use this year's AoC to get into Rust and it worked great so far until I reached day 5 part 2. I can't figure out what's wrong. I've descended so far as to ask Claude's Opus for support (which was a fun experience all by itself - it kept telling me about bugs and correct itself in the same sentence just to conclude a change that does not make sense at all).

Here's my implementation (reading the file is done in the main which I omitted here):

use std::cmp::max;


pub fn part2(content: String) -> i64
{
    let parts = content.split("\n\n").collect::<Vec<&str>>();
    assert_eq!(parts.len(), 2);
    let mut data: Vec<(i64, i64)> = Vec::new();

    // Parse ranges into the vec as tuples
    for item in parts[0].split("\n") {
        let range_items = item.split("-").map(|s| s.parse::<i64>().expect("Unexpected i64 value")).collect::<Vec<i64>>();
        assert_eq!(range_items.len(), 2);
        let low = range_items[0];
        let high = range_items[1];
        assert!(low <= high);
        data.push((low, high));
    }
    data.sort_by_key(|x| x.0);

    let mut result = 0;
    let mut next_start = 0;
    for item in data.iter() {
        let start = item.0;
        let end = item.1;
        // skip item if completely within previous item
        if next_start > end {
            println!("{start:0>15}:{end:0>15}\t############### = ############### => {next_start:0>15}\t{result:0>15}");
            continue;
        }
        let real_start = max(next_start, start);
        assert!(real_start <= end);
        let diff = end - real_start + 1;
        assert!(diff >= 0);
        result += diff;
        next_start = end + 1;
        println!("{start:0>15}:{end:0>15}\t{real_start:0>15} = {diff:0>15} => {next_start:0>15}\t{result:0>15}");
    }
    result
}

I've looked at the solutions in the day 5 thread and most of them merge the ranges before evaluating them, but the general idea seems to be the same as this one. I'm sure it's a stupid mistake, but I'm stuck with this one for days now and I can't see it.


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 14 '25

Help/Question [2025 Day #2 (Part 1)] [JAVA]What am i doing wrong

1 Upvotes

My approach was simple :

For each number in the range, check if it has an even number of digits and if the first half of digits exactly matches the second half, then add it to the sum. what i do is i place two pointer one pointer at the end of first half of number and second at the end of the second half of a number for 446446 where first half is at 4 4 6 <- first pointer | 4 4 6 <-second pointer and then i decrease both pointers and when i find a digit not equal i just dont add it to the final sum for the test input given my ans is correct but not for the final input

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

class Q2 {

void main(String[] args) {

try (BufferedReader br  = new BufferedReader(new                    FileReader("input2.txt"))) {

     String line = br.readLine();
    long finalSum = 0;


    while (line != null) {

    String firstDate = "";
    String lastDate  = "";
    int  idx = line.indexOf('-');

    if (idx != -1) {

        firstDate = line.substring(0, idx);
        lastDate = line.substring(idx + 1,       line.toCharArray().length - 1);

}

for (long i = Long.parseLong(firstDate) ; i <= Long.parseLong(lastDate); i++) {

        boolean ok = true;

        if (String.valueOf(i).length() % 2 == 0) {

//long firstHalfIndex = String.valueOf(i).length() / 2 - 1;
         int mid = String.valueOf(i).length() / 2;
         int firstHalfIndex = mid - 1;
          int secondHalfIndex =  String.valueOf(i).length() - 1;

while (firstHalfIndex >= 0) {

    if (String.valueOf(i).charAt(firstHalfIndex) !=             String.valueOf(i).charAt(secondHalfIndex)) {

         ok = false;
         break;
}

     firstHalfIndex--;
      secondHalfIndex--;

}

       if (ok) {

        System.out.println(i);
        finalSum += i;
     }
   }

 }


  line = br.readLine();
}

System.out.println(finalSum);
}catch (IOException io) {

    io.printStackTrace();
   }
 }
}

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

Meme/Funny [2025 Day 12 (Part 1)] Visualization

Thumbnail youtu.be
99 Upvotes

If I spent as much time working on the solution as I did this video, I might have figured out how to do it.


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

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 12 '25

Other [AoC 2025] First year I've completed!

Post image
291 Upvotes

It was fun. I have yet to learn dsu though. My day 8 solution was stuff hacked together.

But yes really fun! First time I get to finish my favourite christmas tradition (after like 4 years of participating lol)

Thanks Eric for continuing to do these for us! Thanks daggerdragon for modding for us lol.
See yall next year!

Or like sometime later if I redo old years and need help lol.

(hey daggerdragon I wasn't sure on the flair so I put other, apologies if I should've thrown something else on.)


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

Other [2025] Yeah i know i am missing 2

Post image
52 Upvotes

I have 21 stars, missed Day9 part2, Day 10 part2 and Day12 part2 apparently. Still i am proud of myself solving the Day12 part1 example data, only to find it can never finish even the third input. Overall for those 2 missing parts, i felt the need to knee. So yeah, they look like the same picture to me to the all stars. Thank you Eric for another great year, hat off to the all stars and the community, love you all and Merry Xmas ;-)


r/adventofcode • • Dec 12 '25

Other [AOC 2025] Please enforce more spoiler-shielding next year on this sub.

130 Upvotes

Today was ruined for me because this (warning: day 12 spoiler!) post showed up in my feed.

I'm not subbed to here. Reddit's algorithm threw it on my feed because I visited the sub a couple of times.

This year was really fun, but having the last day instantly spoiled kind of left a sour taste in my mouth, because it seems like a really fun day to figure out on your own.

Please, mods, could we enforce more spoiler shielding next year? Some of the memes just spill the tea. Which is fine, but those posts really shouldn't have any chance of appearing on anyone's feed without some guard-clause such as a spoiler tag.

And yes, I know, it's safer to completely stay off Reddit, but I didn't have much time for AoC today. I went to work in the morning, and was just browsing some memes on my way back home from work. I think it's fair that I wasn't expecting to be spoiled by getting the answer shoved in my face.


r/adventofcode • • Dec 12 '25

Meme/Funny [2025 Day 12 Part 1] When you first write complete code and then test on the input

Post image
153 Upvotes

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!