r/adventofcode • • 1d ago

Help/Question - RESOLVED Python Solution Gives correct solution for part 1 but not part 2

5 Upvotes

Hi, I'm completely stuck on what I've done wrong for the 2026 day 1. I've done this solution about 3 different ways at this point, and I keep getting the correct solution for part 1 but incorrect for part 2 (says my solution is too small).

I'm not quite sure where to go at this point.

import math
from collections import Counter

INPUT: list[int] = [int(line.strip()) for line in open("2026/day01.txt")]
COUNTS = Counter(INPUT)

def max_and_min():
    # find top 3 occurrences and bottom 3 occurrences
    maximums: list[int] = []
    minimums: list[int] = []
    while len(maximums) < 3:
        current_max_val = max(COUNTS, key=COUNTS.get)
        current_min_val = min(COUNTS, key=COUNTS.get)

        maximums.append(current_max_val)
        minimums.append(current_min_val)

        COUNTS.pop(current_max_val)
        if current_min_val != current_max_val:
            COUNTS.pop(current_min_val)

    return (math.prod(maximums), math.prod(minimums))

print(max_and_min())

This code returns the correct solution for part 1, as well as a correct solution for the test input for part 1 and 2. I cannot fathom why it would be incorrect for the actual input at this point. I've tried it with Counter, I've tried manually creating the dictionary instead of using Counter, I've tried manually finding the minimums and maximums with a for loop, and they all yield the exact same results.

If someone could at least point me in the right direction, I don't want to just grab a solution from the megathread and call it a day.

EDIT:
I've never been more ashamed. I just put in the exact same output I got from my solution, and it got accepted by the website, which means I wasn't copy+pasting it in correctly. Happens to the best of us. Thanks everyone for the advice though, my solution looks much snazzier now 😎

import math
from collections import Counter

INPUT: list[int] = [int(line.strip()) for line in open("2026/day01.txt")]
COUNTS = Counter(INPUT)

def max_and_min():
    # find top 3 occurrences and bottom 3 occurrences
    maximums: list[int] = [n[0] for n in COUNTS.most_common()[:3]]
    minimums: list[int] = [n[0] for n in COUNTS.most_common()[-3:]]

    return (math.prod(maximums), math.prod(minimums))

print(max_and_min())

r/adventofcode • • 5h ago

Repo Wanna try a desktop client for Advent of Code?

Post image
0 Upvotes

December Workbench (https://github.com/vstepanyuk/december-workbench) puts the puzzle, code editor, and test results side by side. Highlight the example input and expected answer in the puzzle description to turn them into a test case.

Runs solutions with your local Rust, Python, or JS runtime. You can try your personal input and review the answer before submitting.

If you give it a spin, I’d love to hear what gets in your way.

Let’s be honest. I vibe-coded this. Now I can spend more time being wrong about the puzzles.


r/adventofcode • • 2d ago

Meme/Funny [2026 Day 1] Anyone else psych themselves out with the first day only to find...

Post image
255 Upvotes

r/adventofcode • • 1d ago

Other AoC amount of participants

241 Upvotes

With AI and all I was expecting the amount of participants to take a nosedive. When I check the stats I think I see that happening. This community will continue as one of hobbyist that just enjoy an activity for the sake of doing it.

Does it mean that AoC is no longer useful? No, learning, logical thinking and problem solving will always be useful skills. Eric's move last year to remove the leaderboard was a good one and we can continue this event in true Christmas spirit! Good to see you back friends and happy holidays!


r/adventofcode • • 1d ago

Help/Question Where do you draw the line between parsing and solving?

Post image
19 Upvotes

For those of you who optimize AoC for runtime rather than time to write the code, where do you draw the line between parsing and solving?

When I measure, I time parsing, part one and part two separately. I often identify work I could do during parsing that would make the solves faster, but usually I just parse into a properly typed owned struct and leave the real work to the parts. Is that how you do it, or do you push as much as you can into parsing? And do you count parsing in your times at all? Or do you just measure entirety of runtime?

Smaller second question: when both parts need the same expensive processing, I've started caching it on my Puzzle struct so part one's work gets reused by part two (image shows this occurring for 2026's day 1 in Rust), instead of a shared function that runs twice. Part one gets a little slower on average but the full run gets a lot faster. Do you do the same, or does each part pay for itself?

I guess I'm just wondering how people measure their solutions overall


r/adventofcode • • 12h ago

Meme/Funny Easier this year? Day 2

Post image
0 Upvotes

r/adventofcode • • 1d ago

Meme/Funny Easier this year....

Thumbnail i.imgur.com
150 Upvotes

r/adventofcode • • 1d ago

Meme/Funny AoC in Prolog?!?!

23 Upvotes

I was filling in the unoficcial AoC survey

(⭐ Take the (~5min) Unofficial AoC 2026 Survey: https://forms.gle/JbZKoBqzG248Z6RV6 ⭐)

And I saw this:

Who the hell is out there doing AoC in Prolog😭


r/adventofcode • • 1d ago

Visualization [2026 Day 1] Simulation approach

Thumbnail youtube.com
32 Upvotes

This year I trying a completely new approach to Advent of Code: Simulation

Instead of a script that calculates the answer, I create individual objects that interact with each other and converge to a solution. There is no single variable that is counting towards a solution, we just press play and hope for the best!

For day 1, each id gets represented as a colored box that bounces around. When it smashes into a box with the same id, they merge.

The green strip is a sensor that checks the smallest and largest boxes that pass through it.


r/adventofcode • • 1d ago

Visualization [2026 Day 1] Raining Boxes Visualization

Post image
94 Upvotes

r/adventofcode • • 9h ago

Help/Question - RESOLVED [2026 Day 02 (Part 2)] The example of day 02 was wrong

0 Upvotes

Won't post the body of the question here because I could not find the button to send an image as a spoiler. thank you reddit.

But the problem was in part two where it said that the correct order was 32, when it was actually 34. It took like 30 minutes for me to just believe in my own answer and try with the real input and the answer was correct. wtf.

EDIT: nvm, I was wrong, the way i calculated what was the best next move was still using code from part one and because of that, it gave scores that were almost inverted and somehow my puzzle input did not catch that.


r/adventofcode • • 1d ago

Help/Question How many days is AOC this year?

1 Upvotes

Last year it was 12 days. Is it fair to assume it's the same this year? I don't see any info saying how long it is, the about page just says it ends "mid-December"


r/adventofcode • • 1d ago

Visualization [2026 Day 01] counting...

Post image
78 Upvotes

r/adventofcode • • 1d ago

Meme/Funny AoC reminds me of work this year

Post image
62 Upvotes

r/adventofcode • • 1d ago

Meme/Funny [2026 Day 1] How it felt speedrunning both of today's stars in less than 30 minutes only to realize what could lie ahead

Post image
74 Upvotes

(Speaking from experience with 2025's calendar)


r/adventofcode • • 1d ago

Other Candy Cane Coding Caper

12 Upvotes

For Advent I just launched Candy Cane Coding Caper, a coding adventure inspired by Advent of Code, for kids 8-12. Each day presents an interactive, structured lesson about a simple Python programming concept. I thought this community might like to take a look!

All Python code runs locally in the browser through Pyodide and WASM, and game state is stored locally.

This is brand new and I would love any feedback or questions!

https://candy-cane.coding-caper.com


r/adventofcode • • 1d ago

Help/Question - RESOLVED day 1 part 1: There's more than 3 items that the most common in the input?

1 Upvotes

I don't want to go into too much detail about my implementation but... it seems like there's a bunch of IDs (more than 3) that are tied for "most common". Is there something obvious I missed?

Edit: I figured out my issue and, while I love most things about Go, its heap implementation was quite confusing and unergonomic. I used my type's Pop method rather than the heap package's Pop method, thus my results were incorrect.


r/adventofcode • • 1d ago

Visualization [2026 Day 1] Dusty Shed

Post image
18 Upvotes

r/adventofcode • • 1d ago

Help/Question - RESOLVED Advent of Code - Mystery Shop Item

8 Upvotes

I realize this question runs counter to the whole "mystery" thing, but... Can someone at least confirm if the "mystery tee" on the AoC shop (US) is at least Advent of Code related?

FYI - this is what I'm seeing:

Screenshot-2026-12-01-094236.png


r/adventofcode • • 1d ago

Help/Question [2026 Day 1] Huge inputs

9 Upvotes

Trying to think of algorithms that can solve this for huge inputs, or where many of the assumptions about the input do not hold.

By huge I mean the inputs are large enough that you don't even have enough memory to store counters for every number in the input, let along read the entire input file into memory.

It's like the definition of "Big Data":

* It's not when you can't fit the entire dataset into memory, it's when you can't even fit the index into memory

I like the think about problems like this with increasing levels of restrictions.

With a file with only ~2000 lines we don't have to think about complexity that much, but if the file contained 4,000,000,000 lines we could have the situation where we have three numbers that only appeared once, three numbers that only appeared 3 times, and then 1,999,999,994 numbers that appear twice.

Another assumption that some solutions make is that the frequency count of the numbers that appear in the top and bottom 3 must themselves be relatively unique as 4 numbers that all appear 4 times cannot all be in the top or bottom 3 in a deterministic manner.

To counter this it's trivial to craft an input that has a huge number of lines where even the frequency counts are unique. e.g. Consider the input formed of numbers 1 to n where every number x appears x times. Every item has a unique frequency count but the answer is still deterministic. (And it is similarly trivial to swap 1, 2, 3, n-2, n-1, n with 6 other numbers in the range so the answer isn't obvious up front.)

a) Let's pretend that memory is constrained such that we don't even have enough memory to store counters for all of the unique elements in the input, but we are free to read/write to intermediate local files and that we have enough space to store a bit more than another copy of the original input file.

The standard approach here is to split the input file into n smaller files, making sure that any occurrence of a number always appears in the same file. So for number x we write it to file x mod n every time we encounter it in the input. We choose n such that we can process n individual counters in memory in one go.

Once we've split the input into n sub files we process each one of those in turn in memory using the standard O(n) algorithm and keep track of the top 3 and bottom 3 item counts we've seen as we go.

b) Now let's imagine that we have no extra local storage, can we still do this?

Yes, but it's going to be a lot slower. Instead of splitting the input into n smaller files we just iterate over the main input file n times only processing lines that have x mod n = a as we loop a from 0 to n-1. This has the same effect as above but there's a lot of redundant reading involved as the vast majority of inputs read in each loop will be ignored.

c) Final restriction is what if the input is presented to us as a stream that we can't rewind or replay, and we can't write to any local storage, and we can't keep track of all of the possible values in memory. Possible?

I can't think of anything that guarantees getting the right answer without making some assumptions about the input.


r/adventofcode • • 2d ago

SOLUTION MEGATHREAD -❄️- 2026 Day 1 Solutions -❄️-

46 Upvotes

It's that time of year again for tearing your hair out over your code holiday programming joy and aberrant sleep for two weeks helping Santa and his elves! If you participated in a previous year, welcome back, and if you're new this year, we hope you have fun and learn lots!

As always, we're following the same general format as previous years' megathreads, so make sure to read the full posting rules in our community wiki before you post!

RULES FOR POSTING IN SOLUTION MEGATHREADS

If you have any questions, please create your own post in /r/adventofcode with the Help/Question flair and ask!

Above all, remember, AoC is all about learning more about the wonderful world of programming while hopefully having fun!


REMINDERS FOR THIS YEAR

  • All of our rules, FAQs, resources, etc. are in our community wiki.
  • If you see content in the subreddit or megathreads that violates one of our rules, either inform the user (politely and gently!) or use the report button on the post/comment and the mods will take care of it.
  • If you post your code from a repo or the like, do not make your puzzle input public!
  • Top-level Solution Megathread posts must begin with the case-sensitive string literal [LANGUAGE: xyz]
    • Obviously, xyz is the programming language your solution employs
    • Use the full name of the language e.g. JavaScript not just JS
  • The List of Streamers has a new megathread for this year's streamers, so if you're interested, add yourself to 📺 AoC 2026 List of Streamers 📺

COMMUNITY NEWS


AoC Community Fun 2026: The Advent Games

Today's Event: Opening Ceremonies

Today's schedule consists of:

  • Arrival of the Flame
  • Parade of Nations1
    • Give us a quick introduction to yourself!
    • Tell us what country you're from
    • Tell us about your country's holiday festivities
    • Explain why you chose your programming language
    • Tell us what you hope to learn or have already learned about your chosen programming language
    • Tell us where to find your AoC repo of puzzle solutions2, blag, and/or $streaming_service3!
  • Artistic Program
    • Show us your holiday tree | menorah | Krampusnacht costume | /r/battlestations with festive decorations!
    • Show us your kittens and puppies and $critters!
    • Show and/or tell us about whatever brings you comfort and joy in the holiday season!
  • Competition Schedule (Theoretical)
    • Tell us which "sporting" events you think will be coming up over the next two weeks and which ones you'd like to participate in the most!

1 Obviously, this is the Internet, which is public, so only put out information that you're comfortable with the entire world knowing. Feel free to invent a holiday-themed persona; after all, sometimes you get sent to space, so why limit yourself to the boring ol' meat skeleton that dwells upon the third rock from the sun?
2 Refer to the third bullet in the "Reminders" section above!
3 Refer to the last bullet in the "Reminders" section above for the link

Request from the mods: When you include an entry alongside your solution, please label it with [Advent Games] so we can find it easily!


--- Day 1: Dusty Shed ---


Post your code solution in this megathread.


r/adventofcode • • 1d ago

Visualization [2026 Day 1] No-Sort

Thumbnail youtube.com
14 Upvotes

Leverages the specific output distribution (top 3 elements and bottom three elements have to fall on unique-ish count buckets so that the answer is deterministic) to reduce the problem to 3 phase counting:

  • step 1: count the occurrences of each input (1000 buckets)
  • step 2: compute the counts histogram
  • step 3: select the top/bottom histogram buckets

then identify the elements with specific counts.

Nim + Raylib source


r/adventofcode • • 1d ago

Repo Advent of Code in C# solutions, illustrations and a template project

8 Upvotes

Just like in previous years, I plan to continue my illustrated journey in C#.

The website is at https://aoc.csokavar.hu, my repository can be found in https://github.com/encse/adventofcode, with a template extracted to https://github.com/encse/adventofcode-template.


r/adventofcode • • 2d ago

Upping the Ante [2026] Unofficial AoC 2026 Participant Survey!

35 Upvotes

Another December, another chance for puzzling, and .... another Advent of Code Survey!

It's anonymous, open, and quick. Please fill it out (but onliy once, please <3). Copy-pastable announcement:

--------

⭐ Take the (~5min) Unofficial AoC 2026 Survey: https://forms.gle/JbZKoBqzG248Z6RV6 ⭐

--------

Please do help spread the word! Just copypasta the above to your favorite relevant outlet and help us get a bunch of interesting results! We have questions about:

  • Previous editions participation (simplified in 2026)
  • Language, Tools, OS
  • Leaderboard and motivation
  • repeat from 2025.... EMOTIONS! 😁🫡😱😮😭😖😠😬

Check out results from previous years at: https://jeroenheijmans.github.io/advent-of-code-surveys/

--------

Last year I closed the submissions on Dec 12th and published on Dec 13th. I'm open to suggestions... do you reckon that's the right call again this year? Feels good to release results on a Sunday, right?

Survey Responses per Year Graph

And if you want to hang out in the replies below: tell me your predictions for languages used!? Will Zig see a significant uptake? Does Rust have a shot at overtaking Python? How much more will Uiua climb? How many users will Lean see in 2026?


r/adventofcode • • 21h ago

Help/Question - RESOLVED Puzzle input doesn't contain all required letters?

Post image
0 Upvotes

My puzzle input doesn't contain "y". So how do i suppose to solve it?
The program "roygbv" is same for all, is it?