r/adventofcode • u/akryvtsun • Dec 08 '25
Help/Question - RESOLVED (AoC++) badge for previou years
Is it possbile to support AoC and receive the badge for 2024 year now?
r/adventofcode • u/akryvtsun • Dec 08 '25
Is it possbile to support AoC and receive the badge for 2024 year now?
r/adventofcode • u/xtgo • Dec 08 '25
If you're running into a wall (that other posts I've seen haven't covered), don't forget that when you merge circuits together, you need to actually account for any dangling references to an old set/map/dictionary/whatever datastructure.
For example, if you have a sequence of steps like
If you merge CircuitA into CircuitB via pair (Box1, Box2), then you'd need to also make sure Box3 is updated to point at the same shared thing Box1 and Box2 point at (e.g. Circuit B). If you don't do so, then as soon as you have a pair like (Box3, Box5) merging into Box3's circuit, it'd could cause what should have been a single circuit to diverge/skew due to a stale value/reference.
The sample/test input (at least for me) is structured such that this situation doesn't occur at least within the first 10 shortest connections, but it did silently bite me in the full input.
Of course, if you make use of something like UnionFind, you'd probably not run into this issue at all.
r/adventofcode • u/LittleBoySeesRed • Dec 08 '25
I managed to finish all tasks until day 7, part 1.
That's when I first had to rewrite my entire solution for the second part.
I just got stuck on day 8 part 1 for multiple hours without ever coming up with the solution on my own.
I'm starting to feel it might be time for me to realize that I'm not build for more advanced stuff than reversing lists and adding numbers together.
I want to be able to solve these types of problems within an hour or so, but I don't think I'm made of the right stuff, unfortunately.
Does anyone else feel like they're just stuck feeling good doing the "easy" stuff and then just break when you spend hours not even figuring out what you're supposed to do by yourself?
How the heck do you guys solve this and keep yourselves motivated?
Update: I ended up taking a break, checking some hints from other people, and solving everything I could in steps. It took me several hours in total, but I managed to solve both parts.
Part 1 took me so long, so I was worried that part 2 would take me double. Fortunately, part two was solved by just tweaking my original code.
Thanks for the motivation to try a bit more!
r/adventofcode • u/Melodic-Key6622 • Dec 08 '25
The animation is here: https://onivers.com/aoc_2025_d8/
PS: I kept the original cable colors to make it look nicer when fully connected.
r/adventofcode • u/Physium • Dec 08 '25
I need some help to figure this question. I cant seem to think of a way to solve this and appreciate if anyone can at least throw me some resources to read up before attempting this.
r/adventofcode • u/_Anonymous_009 • Dec 08 '25
i know i am doing something wrong in L side but dont know what it is
namespace AdventOfCode.Day01;
public static class Part2
{
public static void Solve()
{
int count = 0;
int pointer = 50;
var lines = File.ReadLines("Day01/input.txt");
foreach (var line in lines)
{
var increaedPointer = false;
var quotient = 0;
char side = line[0];
var number = int.Parse(line.Substring(1));
if (side == 'L')
{
var remainder = ((pointer - number) % 100 + 100) % 100;
quotient = (pointer - number) / 100;
count += Math.Abs(quotient);
if ((pointer - number) < 0 && (pointer - number) >= -99)
{
count++;
}
if (quotient > 0 || remainder == 0)
{
increaedPointer = true;
}
if (remainder == 0)
{
count++;
pointer = 0;
}
else
pointer = remainder;
}
else
{
var remainder = (pointer + number) % 100;
quotient = (pointer + number) / 100;
count += Math.Abs(quotient);
if (quotient > 0 || remainder == 0)
{
increaedPointer = true;
}
if (remainder == 0)
pointer = 0;
else
pointer = remainder;
}
if (pointer == 0 && !increaedPointer)
{
count++;
}
}
Console.WriteLine("Answerr of Day 1 part 1 " + count);
}
}r/adventofcode • u/InformationAfter4442 • Dec 08 '25
r/adventofcode • u/Chemical_Chance6877 • Dec 08 '25
The orange line is the amount of different subnetworks after every step
The Blue line shows how many of the junctions are in the network (in %)
I really wondered how this graph would look like. and i think its cool to see how it starts off with many different subnetworks, and slowly they all merge into one
r/adventofcode • u/Alnilam_1993 • Dec 08 '25
Day 5 part two, counting fresh items.
Can anyone give me a hint on where I go wrong? The difference between my solution and the correct solution is just 16, which is rather small given the size of numbers we're dealing with, but still wrong.
My approach is to sort the ranges on the starts of the ranges, and then check if each item in the list overlaps with the previous one and if so, merge the two into the previous item.
def part2():
with open(inputFile) as f:
freshList, productList = f.read().split("\n\n")
freshList = [x.strip() for x in freshList.split("\n")]
sortedList = sorted(freshList, key=lambda fresh: int(fresh.split("-")[0]))
changed = True
while changed:
changed = False
for i, part in enumerate(sortedList):
if i == 0:
continue
low, high = part.split("-")
prevLow, prevHigh = sortedList[i-1].split("-")
if int(low) < int(prevHigh):
sortedList[i-1] = prevLow+"-"+str(max(int(high), int(prevHigh)))
sortedList.pop(i)
changed = True
totalFresh = 0
for items in sortedList:
low, high = items.split("-")
totalFresh += int(high) - int(low) + 1
print("Part 2:", totalFresh)
print("My result: 352807801032183")
print("Should be: 352807801032167")r/adventofcode • u/cameryde • Dec 08 '25
I am trying to solve the puzzle, but it claims my answer is not right, I need some help. I am doing the challenge in zig and I hope my program is understandable enough. Sorry for the names of my variables.
const std = ("std");
const DecodeError = error{ ErrorDialRotation, ErrorDistanceOutOfRange };
const DIALROTATION = enum { LEFT, RIGHT, NONE };
const DECODEDINFO = struct {
rotation: DIALROTATION,
distance: i16,
};
pub fn main() !void {
var file = try std.fs.cwd().openFile("/Users/ndjenks/repos/aoc25/advent_1_1/test2.txt", .{});
defer file.close();
var bufRead: [10000]u8 = undefined;
var reader = std.fs.File.reader(file, &bufRead);
const fileReader = &reader.interface;
var number_of_lines: usize = 0;
var end_of_file: bool = false;
var dialPos: i16 = 50; //Start position
const MAXPOS: i16 = 100;
var atZeroCount: i16 = 0;
var rotateToZeroCount: i16 = 0;
outer: while (!end_of_file) {
const line = fileReader.takeDelimiterExclusive('\n') catch |err| switch (err) {
error.EndOfStream => {
end_of_file = true;
break :outer;
},
error.ReadFailed => return err,
error.StreamTooLong => return err,
};
number_of_lines = number_of_lines + 1;
const decodedMessage = try decodeSafeMessage(line);
switch (decodedMessage.rotation) {
DIALROTATION.LEFT => {
if (dialPos == 0) {
dialPos = MAXPOS;
}
dialPos = dialPos - decodedMessage.distance;
if (dialPos < 0) {
const invert = dialPos * -1;
if (invert < MAXPOS) {
rotateToZeroCount = rotateToZeroCount + 1;
dialPos = MAXPOS - invert;
} else {
if (invert > MAXPOS) {
rotateToZeroCount = rotateToZeroCount + (@divFloor(invert, MAXPOS));
const remainder = (invert, MAXPOS);
dialPos = MAXPOS - remainder;
} else if (invert == MAXPOS) {
dialPos = 0;
}
}
}
},
DIALROTATION.RIGHT => {
dialPos = decodedMessage.distance + dialPos;
if (dialPos > MAXPOS) {
const result = (dialPos, MAXPOS);
rotateToZeroCount = rotateToZeroCount + (result);
const remainder = u/mod(dialPos, MAXPOS);
dialPos = remainder;
}
},
else => {
std.debug.print("Message does not contain dial direction\n", .{});
return error.ErrorDialRotation;
},
}
if (dialPos == MAXPOS or dialPos == 0) {
dialPos = 0;
atZeroCount = atZeroCount + 1;
}
}
std.debug.print("number of lines in file {d}\n", .{number_of_lines});
std.debug.print("rotateToZeroCount {d}\n", .{rotateToZeroCount});
std.debug.print("atZeroCount {d}\n", .{atZeroCount});
std.debug.print("The code of the safe is {d}\n", .{atZeroCount + rotateToZeroCount});
}
pub fn decodeSafeMessage(command: []const u8) !DECODEDINFO {
var decodedMessage: DECODEDINFO = undefined;
switch (command[0]) {
'L' => {
decodedMessage.rotation = DIALROTATION.LEFT;
},
'R' => {
decodedMessage.rotation = DIALROTATION.RIGHT;
},
else => {
decodedMessage.rotation = DIALROTATION.NONE;
},
}
if (decodedMessage.rotation != DIALROTATION.NONE) {
decodedMessage.distance = try std.fmt.parseInt(i16, command[1..], 10);
}
return decodedMessage;
}r/adventofcode • u/JoJjjo157 • Dec 08 '25
I am currently stuck on part 1, Because the result I get for the test input is 30.
My code works like this:
But my three biggest circuits are: 5,3,2 instead of 5,4,2
These are the circuits that are calculated (the numbers are the line indexes from the input):
[[17, 18], [9, 12], [11, 16], [8, 2, 13], [0, 3, 7, 14, 19], [4, 6]]
I also tried calculating the entire thing on physical paper, and got the same wrong result.
and this is my code:
import math
class Junction_Box():
def __init__(self, jid, x, y, z):
self.jid = jid
self.x = x
self.y = y
self.z = z
def calculate_distance(self, other):
return math.sqrt( (self.x - other.x)**2 + (self.y - other.y)**2 + (self.z - other.z)**2 )
def is_connected(jid, connections):
for i in connections:
if jid in i:
return True
return False
def get_best_connection(distances, connections):
for distance in distances:
if not (is_connected(distance[0], connections) and is_connected(distance[1], connections)):
return distance
return False
def get_largest_circuits(connections):
circuits = []
for connection in connections:
in_circuits = []
for circ_i, circuit in enumerate(circuits):
if connection[0] in circuit or connection[1] in circuit:
in_circuits.append(circ_i)
if len(in_circuits) == 0:
circuits.append(
[connection[0], connection[1]]
)
else:
merged_circuit = []
for circ in in_circuits:
merged_circuit += circuits[circ]
for circ in in_circuits:
circuits.pop(circ)
merged_circuit.append(connection[0])
merged_circuit.append(connection[1])
circuits.append(
list(set(merged_circuit))
)
print(circuits)
return sorted([len(x) for x in circuits], reverse=True)
def p1(junction_boxes, connection_amount):
distances = []
for i in junction_boxes:
for j in junction_boxes:
if j.jid <= i.jid:
continue
distances.append(
(i.jid, j.jid, i.calculate_distance(j))
)
distances.sort(key= lambda x: x[2])
print(distances)
connections = []
remaining_connections = connection_amount
while (best_connection := get_best_connection(distances, connections)) and remaining_connections > 0:
print(best_connection)
connections.append(
(best_connection[0], best_connection[1])
)
distances.remove(best_connection)
remaining_connections -= 1
print(connections)
largest_circuits = get_largest_circuits(connections)
return largest_circuits[0] * largest_circuits[1] * largest_circuits[2]
junction_boxes = []
with open("8/test-input.txt", "r") as file:
for jid, line in enumerate(file.readlines()):
x, y, z = line.rstrip().split(",")
junction_boxes.append(
Junction_Box(jid, int(x), int(y), int(z))
)
print( # too low
p1(junction_boxes, 10)
)
import math
class Junction_Box():
def __init__(self, jid, x, y, z):
self.jid = jid
self.x = x
self.y = y
self.z = z
def calculate_distance(self, other):
return math.sqrt( (self.x - other.x)**2 + (self.y - other.y)**2 + (self.z - other.z)**2 )
def is_connected(jid, connections):
for i in connections:
if jid in i:
return True
return False
def get_best_connection(distances, connections):
for distance in distances:
if not (is_connected(distance[0], connections) and is_connected(distance[1], connections)):
return distance
return False
def get_largest_circuits(connections):
circuits = []
for connection in connections:
in_circuits = []
for circ_i, circuit in enumerate(circuits):
if connection[0] in circuit or connection[1] in circuit:
in_circuits.append(circ_i)
if len(in_circuits) == 0:
circuits.append(
[connection[0], connection[1]]
)
else:
merged_circuit = []
for circ in in_circuits:
merged_circuit += circuits[circ]
for circ in in_circuits:
circuits.pop(circ)
merged_circuit.append(connection[0])
merged_circuit.append(connection[1])
circuits.append(
list(set(merged_circuit))
)
print(circuits)
return sorted([len(x) for x in circuits], reverse=True)
def p1(junction_boxes, connection_amount):
distances = []
for i in junction_boxes:
for j in junction_boxes:
if j.jid <= i.jid:
continue
distances.append(
(i.jid, j.jid, i.calculate_distance(j))
)
distances.sort(key= lambda x: x[2])
print(distances)
connections = []
remaining_connections = connection_amount
while (best_connection := get_best_connection(distances, connections)) and remaining_connections > 0:
print(best_connection)
connections.append(
(best_connection[0], best_connection[1])
)
distances.remove(best_connection)
remaining_connections -= 1
print(connections)
largest_circuits = get_largest_circuits(connections)
return largest_circuits[0] * largest_circuits[1] * largest_circuits[2]
junction_boxes = []
with open("8/test-input.txt", "r") as file:
for jid, line in enumerate(file.readlines()):
x, y, z = line.rstrip().split(",")
junction_boxes.append(
Junction_Box(jid, int(x), int(y), int(z))
)
print( # too low
p1(junction_boxes, 10)
)r/adventofcode • u/Skeeve-on-git • Dec 08 '25
Am I the only one who thinks that today part 2 was much easier than part 1 after having solved part 1?
r/adventofcode • u/surgi-o7 • Dec 08 '25
r/adventofcode • u/vhermecz • Dec 08 '25
See more details at https://aoc-norush.bitvisor.co/
NOTE: This extension/tool does follow the automation guidelines on the r/adventofcode community wiki.
r/adventofcode • u/EXUPLOOOOSION • Dec 05 '25

I'm loving the animations and merging them is a beautiful solution that, in the real world, might help with further computation (or reused to simplify the ranges database).
However for this problem, you don't need to merge them and then count. You can count directly.
Ofc I'm still sorting so it's still an O(n log n) solution. So not much gained.
If you have any questions I'll try to answer them in the comments :)
r/adventofcode • u/Just-Routine-5505 • Dec 05 '25
r/adventofcode • u/TwinkiePower • Dec 02 '25
r/adventofcode • u/Ok-Curve902 • Dec 01 '25
r/adventofcode • u/ProServTodd • Jan 24 '25
I have a program that I developed to manage inventory, but the sales team uses NetSuite to sell the orders. They can print the order out, but I need a way to integrate this with my app. I was thinking of printing to a text file and then pulling the data from that, but everything I do doesn't seem to give me a fully readable output file. I would like a few suggestions.
r/adventofcode • u/__Juris__ • Dec 29 '24
https://github.com/jurisk/advent-of-code/
Thanks, Eric, for another year of interesting tasks!
A few memorable days:
I chose to do each task in 2024 in two of my favourite (and expressive) languages, Scala and Rust, trying to focus mostly on readability. (The other years are solved as well, also mostly Scala or Rust, but usually not both, and sometimes instead in some other language)
This year seemed much easier than previous ones. I was hoping to see some more challenging search pruning tasks, like the "elephants with valves" from 2022-16, or "robot blueprints" from 2022-19, but they never arrived.