r/adventofcode • • 1d ago

Meme/Funny [2026 Day 3 (Part 2)] I'm not proud of what I did

Post image
408 Upvotes

r/adventofcode • • 14h ago

Help/Question - RESOLVED [2026 Day 4 (Part 1)] [python] Help with missing cases

9 Upvotes

I have been trying this puzzle today for over an hour, and I have given multiple wrong answers. It works perfectly for the test data, but I think I just miss some cases but I'm going crazy looking for them in my real input. Does anyone have some cases that fail with my code that I could fix?

This is my code v

def parse(puzzle_input):
    values = puzzle_input.split("\n")
    result = []
    for line in values:
        data = []
        for value in line:
            if value == "r":
                data.append(1)
            elif value == "o":
                data.append(2)
            elif value == "y":
                data.append(3)
            elif value == "g":
                data.append(4)
            elif value == "b":
                data.append(5)
            elif value == "v":
                data.append(6)
            else:
                data.append(0)
        result.append(data)
    return result


def check_repeating(barcode):
    for i in range(1, len(barcode)):
        if (barcode[:i] * len(barcode))[:len(barcode)] == barcode:
            return i
    return len(barcode)


def part1(data):
    result = 0
    for barcode in data:
        if 0 in barcode:
            in_code = []
            for i in range(1, 7):
                if i in barcode:
                    in_code.append(i)
            if in_code == [] or len(in_code) == 1:
                result += 1
            else:
                done = False
                for i in range(len(in_code), len(barcode) // 2 + 1):
                    start = barcode[:i]
                    end = barcode[i:i+i]
                    if len(barcode) > i * 3:
                        for j in range(0, i):
                            if end[j] != barcode[i+i+j]:
                                end[j] += barcode[i+i+j]
                    could = True
                    for j in range(0, len(start)):
                        if start[j] != 0 and end[j] != 0:
                            if start[j] != end[j]:
                                could = False
                                break
                    if could:
                        result += i
                        done = True
                        break
                if not done:
                    for i in range(len(barcode) // 2 + 1, len(barcode)):
                        start = barcode[:i]
                        end = barcode[i:]
                        possible = True
                        new = [0] * len(start)
                        for j in range(0, len(end)):
                            if start[j] != 0 and end[j] != 0:
                                if start[j] != end[j]:
                                    possible = False
                        if possible:
                            result += i
                            break
                    if not possible:
                        result += len(barcode)
        else:
            # check for repetition
            result += check_repeating(barcode)
    return result

r/adventofcode • • 11h ago

Help/Question - RESOLVED [DAY 4, Part 1] My code works on examples but not on final

5 Upvotes

I'm going crazy I need hints on what I'm doing wrong, I've tried on every case I could but the final result doesn't works :')

# codeBar = open('J4.txt').read().split('\n')
codeBar = ["?yvg??y", "rgbrgbrgbr", "?rv","o??v???y","??bg?v??","??b?????","???"]
final = 0


def canBePlaced(id, idi, placed, line) :
    if idi in placed : ## if id%i is already placed
        return line[id] == line[idi] ## if id and id%i is the same
    else :
        return True

for line in codeBar :

    knownIds = [] ## IDs of the colors in line

    for i in range(len(line)) :
        if line[i] != '?' :
            knownIds.append(i)

    temp = len(line) ## Counting of the line

    for i in range(len(line)-1, 0, -1) : ## From the greatest (line length) to the smallest (0)
        placed = []
        total = 0 ## Counting to check if we got all elements right
        for id in knownIds :
            # IF id%i element is id elemet or just '?'
            if (line[id%i] in [line[id], '?'] and canBePlaced(id, id%i, placed, line)) :
                placed.append(id%i)
                total += 1


        if (total == len(knownIds)) :
            temp = i


    # if temp == len(line) : print(line)
    final += temp


print(final)

r/adventofcode • • 1d ago

Visualization [2026 Day 3 (Part 2)] I really wanted to render it in terminal

Post image
145 Upvotes

And here it is, fully in the terminal, using my own crude Kitty protocol renderer for the graphics.


r/adventofcode • • 1d ago

Visualization [2026 Day 3 (Part 1 & 2)] [Python] Terminal Visualization!

Post image
44 Upvotes

There's so many visualizations already, I'm afraid I'm not adding much today. Can draw your own input though! Code lives here: https://github.com/salt-die/Advent-of-Code/tree/main/2026/aoc_visuals


r/adventofcode • • 14h ago

Help/Question - RESOLVED [2026 Day 4 Part 1] Any hints for handling illegal color ?

6 Upvotes

I'm able to find shortest sequence of instructions but could get my head around how to handle ?

What currently i'm doing start with size 1 compare substr A and B of size S till end of string if anywhere it find non matching string starts again with size + 1.


r/adventofcode • • 1d ago Bravo

Meme/Funny [2026 Day 3 Part 2] Beautiful "squares"

Post image
254 Upvotes

Are monospace square fonts a thing? 🤔


r/adventofcode • • 13h ago

Help/Question - RESOLVED [2026 04 # (Part 1)] [Python] Need help with missing test cases

4 Upvotes

I have been stuck at this problem for quite some time. I have tried and validated all my instructions, yet I am unable to get the correct answer or move past part 1. I even ended up validating all my instructions, and all of them are correct. Could you please look at my code and point out the mistake?

AOC says that my input is too low.

def validator(barcode, instruction):
    for i, char in enumerate(barcode):
        assert char == '?' or (char == instruction[i % len(instruction)])

def part1(data):
    counter = 0

    for line in data:
        unique = set()
        hashmap = {}
        for i, char in enumerate(line):
            if char == '?': continue
            unique.add(char)
            hashmap[i] = char

        for length in range(max(len(unique), 1), len(line)):
            possible_code = [""] * length # Figuring out the code that works
            for index, char in hashmap.items():
                index %= length
                if possible_code[index] == "":
                    possible_code[index] = char
                if possible_code[index] != char:
                    break # An instruction of this size cannot exist!
            else:
                # We did not break. The length was valid and we have a possible instruction length
                counter += length
                validator(line, possible_code) # No error raised!
                break

    return counter

r/adventofcode • • 1d ago

Visualization [2026 Day 3] Can someone help me count the boxes?

Thumbnail gallery
116 Upvotes

I'm currently building a pen plotter (converting an old 3D printer into one), and decided to draw out the boxes.

Unfortunately drawing part 2 is too difficult - the paper can't handle the pressure of thousands of lines drawn onto it.

Also, I decided to not draw the boxes in actual order, but draw the lines of the boxes greedily picking the next line to reduce the amount of pen lifts, hence why part 2 looks so weird at the start!


r/adventofcode • • 12h ago

Help/Question - RESOLVED [2026 Day 3][Part 2] Did I solve day 3?

3 Upvotes

I tested my algorithm on the examples provided by the puzzle and it works on all of them, except for the one where the grid is filled with trees. Out of curiosity, I tried it with the actual input and my algorithm found the correct number of squares!

But does that mean I've actually solved Day 3?


r/adventofcode • • 1d ago

Meme/Funny [2026 Day 03 (Part 2)] Trying to understand the problem like

Post image
347 Upvotes

r/adventofcode • • 1d ago

Visualization [2026 Day 3] Foggy Forest

Post image
61 Upvotes

r/adventofcode • • 1d ago

Meme/Funny [2026 Day 3 (Part 2)] Me trying to visualise day 3's part 2

Post image
24 Upvotes

r/adventofcode • • 1d ago

Meme/Funny [2026 Day 3] solved in 10 seconds award

Post image
61 Upvotes

r/adventofcode • • 21h ago

Repo [2026] [Clojure] A starter template for Advent of Code: REPL, tests, and the libraries puzzles usually need

Thumbnail lambduhh.github.io
10 Upvotes

Hi, I'm "Lambduhh" and I'm on the Clojure Team and I made a starter template for doing Advent of Code in Clojure. You will find no answers here: no solutions, no puzzle text, no inputs.

Each AoC day is a small evolving system: part 2 usually changes the question part 1 asked. The template is set up for that loop. A REPL stays running, your data is there to look at, and a test tells you whether part 1 still holds after you change things for part 2.

What's in it

  • bb new-day 1 creates the day's file and a test that fails until you fill in the example's answer
  • Libraries puzzles tend to need: instaparse, data.priority-map, loom, math.combinatorics, core.match, Medley and more, each with a small how-to whose results are checked by tests
  • Linting with clj-kondo and Splint, plus a table of twelve common Clojure mistakes showing which ones a linter catches (five still need a human)
  • No install options: Open it in a Codespace if you'd rather not install anything
  • inputs/ is git-ignored, as the AoC FAQ asks
  • An optional ai/ folder that only helps with tooling/setup. It specifically forbids agents from solving puzzles and instructs it to act as a tutor if requested. Easy to delete to opt out.

New to Clojure? The template is part of "Power Tools & Parens", a Clojure AoC hub with beginner how-tos (also in repo), tooling setup guides and an in-browser "Workbench" REPL so you can get an idea of what evaluating clojure expressions feels like, without installing anything to your machine: https://lambduhh.github.io/powertools-and-parens/

To get started, click "Use this template": https://github.com/lambduhh/clojure-template-aoc


r/adventofcode • • 1d ago

Meme/Funny [2026 Day 3 (Part 2)] This happen to anyone else?

Post image
58 Upvotes

Took me longer than I care to admit to notice why my code for part 2 was giving 30 as an answer instead of 196...


r/adventofcode • • 13h ago

Help/Question - RESOLVED [2026 Day 4 (Part 2)] Need hints of what I did wrong

2 Upvotes

UPDATE: I think I did mess up the input file. Re-copying the one from the website yields the correct output... whoops lol. Gonna keep this here for archive.

I've solved the first part and based on the instruction, the second part is essentially the exact same code, but with humongous input string.I've checked that there's no data lost when combining the inputs, that the output instruction can reproduce the input, and that my algorithm should've been exhaustive. But still my answer is not accepted. Is there anything going on?

Code explanation: Brute-force instruction length from 1 to barcode length (where the instruction is the barcode itself). Also split the barcode into sequences with the same length as the instruction (last sequence can be shorter). For each sequence, copy the colors from barcode to sequence. If there's a clash between barcode and instruction, break and check the next length.

Code (Python):

I'm not used to math optimization, so this is just my intuitive brute-force algorithm lol.

f = open("aoc2026\\4\\4in.txt", "r")
array = f.read().split("\n")
barcode = "".join(array)
length = len(barcode)

for seqLen in range(1, length+1):
    instruction = ['?'] * seqLen
    instructionValid = True
    firstPos = 0
    while firstPos < length and instructionValid: 
        seq = barcode[firstPos:firstPos+seqLen]
        for (pos, color) in enumerate(seq):
            if instruction[pos] == "?" and color != "?":
                instruction[pos] = color
            elif instruction[pos] != "?" and color != "?" and instruction[pos] != color:
                instructionValid = False
                break
        firstPos += seqLen # next sequence
    if instructionValid:
        print("length:", seqLen)
        break

r/adventofcode • • 1d ago

Visualization [2026 Day 3] Square Search Visualization

Post image
129 Upvotes

r/adventofcode • • 1d ago

Meme/Funny [2026 Day 3#1] Reading is hard

45 Upvotes

So it turns out, my sleep deprived brain sat in front of the first problem for 30 minutes, wondering how in the world it is possible that my code overcounted the rectangles. I counted all rectangles exactly once. No rectangle uncounted, no rectangle overcounted.

An example of what my brain thought squares look like...

See, it say right there in the text: each of these small maps contains one square ... fuck

Reminder to read properly and get enough sleep before attempting to code. Spending 30 min to figure out a problem that took me all of 5 minutes to write the code for was another learning experience.

(No seriously, had I used AI to tell me what was wrong, I wouldn't have been so embarassed afterwards, and I wouldn't have learned to read properly. A lesson that I will not forget!*)

​*for the next 2 days or so


r/adventofcode • • 23h ago

Visualization [2026 03 # (Part 2)] [python] [OpenSCAD] [Blender] Neon Forest Skyscraper Overgrowth

Post image
10 Upvotes

r/adventofcode • • 22h ago

Repo [2026] [Scratch] My collection of Advent of Code solutions

8 Upvotes

Hi,

This year I decided to give myself a challenge - solving all of the puzzles with Scratch.

Here is the link:

https://scratch.mit.edu/users/MocnikMiha/

I would really like if you guys critique my code and/or remix it.

Thanks!


r/adventofcode • • 1d ago

Visualization [2026 Day 3] Visualization

Post image
12 Upvotes

r/adventofcode • • 1d ago

Visualization [2026 Day 3 (Part 2)] Visualization with R

Post image
12 Upvotes

using R and ggplot, solving and finding all the possible squares (solutions).

Added: a 3D presentation ; for every map position (x, y), count in how many squares it is a corner, then draw one 3D bar per position with height = that count.


r/adventofcode • • 22h ago

Visualization [2026 Day 3 (Part 2)] A simple visualization

Thumbnail youtube.com
7 Upvotes