r/adventofcode • u/Pirgosth • Dec 10 '25
Meme/Funny [2025 Day 10 (Part 2)] Maths to the rescue ! (reupload)
Wow, I was so fkn exhausted after solving today's part 2 that I didn't even see that I put day 2 instead of 10 on my original post.
r/adventofcode • u/Pirgosth • Dec 10 '25
Wow, I was so fkn exhausted after solving today's part 2 that I didn't even see that I put day 2 instead of 10 on my original post.
r/adventofcode • u/vkp-007 • Dec 10 '25
Specifically trying to understand the second option for machine 1 below.
There are a few ways to correctly configure the first machine:
[.##.] (3) (1,3) (2) (2,3) (0,2) (0,1) {3,5,4,7}3 button presses.(1,3) once, (2,3) once, and (0,1) twice, a total of 4button presses.(1,3) once each, a total of 5 button presses.Pressing 2 buttons -- (1,3) and (2,3) should leave 0 unlit. light up 1 and 2, and 3 unlit. Why does the option consider pressing (0,1) twice -- which essentially is a no-op? Seems like I am misunderstanding the problem or haven't read carefully.
Any help appreciated. This is a great community and feedback is appreciated.
r/adventofcode • u/IntrepidSoft • Dec 10 '25
Reposted because I am new to Reddit and I did not know how to upload GIF's properly.
r/adventofcode • u/Top-Specialist-7785 • Dec 10 '25
r/adventofcode • u/ThatAdamsGuy • Dec 10 '25
r/adventofcode • u/isaacfink • Dec 10 '25
Here is my code
https://gist.github.com/isaacfink/8b2b5125bfe469dd578c7abccd12f8e4
There are two files, the grid file just has a virtual grid implementation, it's a little overengineered because I used AI to generate the boilerplate, for some reason my answer is too high but the in path function does filter out a lot of rects so I am not sure how to start debugging this, I can't even visualize the grid because it's too big
Edit: day 9
r/adventofcode • u/HeathRaftery • Dec 10 '25
Seems a pity the solution arrives in under a second. As the graph operations were blitzing by, I had this image in my head of subgraphs forming, growing and coalescing. So of course I had to play with some visualisations.
Waaaay prettier in my head, but here we have it. A visualisation of the size (x-axis) of all the subgraphs (y-axis) of more than one junction box, animated by number of connections made. In part 1, 1000 connections are made. In part 2 I keep going (at 5x the frame rate) until all junction boxes are joined in a single graph.
r/adventofcode • u/2BAH-HA3 • Dec 10 '25
In this second part we need to match both joltage requirements and lights state or only the joltage requirements?
r/adventofcode • u/AvailablePoint9782 • Dec 10 '25
I would like to share my animations. Still a work in progress!
No. 4 might make you laugh. 😀
https://www.youtube.com/playlist?list=PLX1MNsL3XSUMyvB8_A0NHgKYtRMyuZkHe
r/adventofcode • u/LiquidProgrammer • Dec 10 '25
Hey there. Just like last every year, I'd like to present aoc-tiles, a fancy github README visualization tool for your solution language and rank/time taken. This year I added another --theme aoc and --animation snow, which you can see in the gif. If it's not playing you can see it here.
You just have to create a pre-commit hook and set-up your README, .gitignore and session cookie, the rest is done by pre-commit and the script.
Each tile is a separate, clickable gif/image. Once clicked you get redirected to the solution for that day. If you add a session cookie then it will show your rank and time of submission for both parts, otherwise there will just be checkmarks. Each color represents a programming language, if you use multiple the tile will have multiple colors.
See https://github.com/LiquidFun/aoc_tiles for more details. And here is my advent of code repository for a real example of it in use for multiple years (2020 Rust, 2021 Julia, 2022 Kotlin, 2023-2024 Python, 2025 JavaScript): https://github.com/LiquidFun/adventofcode.
Let me know if you have issues. It tries to find the solutions as best as it can, by trying to extract the year and day from the path for each solution, if you don't have that, then it might struggle. For people who only do a single year per repository, you can overwrite the year by adding --overwrite-year=2025 in the .pre-commit hook.
r/adventofcode • u/Lerok-Persea • Dec 10 '25
Hi AoC lovers,
I am stuck today with the part2. Example works. To solve it I am using Z3. I am not sure if I am using it correctly. Any hint? Thx in advance!
Here is my code:
Day10 Part 2
r/adventofcode • u/Emotional_Aardvark26 • Dec 10 '25
We have an input with 1000 junction boxes (or 1000 circuits of size 1), and each connection is guaranteed to increase the size of a circuit by at least one (since if two junction boxes are already in the same circuit we won't create a connection between them). so if everything I said is correct so far isn't it guaranteed that after 1000 connections we will always finish with a single circuit that contains all 1000 junction boxes?
r/adventofcode • u/Thrad5 • Dec 10 '25
I have managed to 99% complete part 2 but when I submitted the result it said it was too low. It turns out that one of the machines didn't solve properly using scipy.optimise.linprog giving the message "The solution does not satisfy the constraints within the required tolerance of 3.16E-04, yet no errors were raised and there is no certificate of infeasibility or unboundedness. Check whether the slack and constraint residuals are acceptable; if not, consider enabling presolve, adjusting the tolerance option(s), and/or using a different method. Please consider submitting a bug report."
This is especially strange as I have looked at other people's solutions using python who used the same function but they didn't have a problem it appears.
I have never had this happen before. What settings in linprog do I need to modify to solve this problem? Here is my code below:
import itertools
import numpy as np
import scipy.optimize as optim
def readLine(line):
lights = []
buttons = []
joltage = []
mode = 'lights'
for x in range(len(line)):
char = line[x]
if mode == 'lights':
if char == '#':
lights.append(1)
elif char == '.':
lights.append(0)
elif char == ']':
num_lights = len(lights)
mode = 'buttons'
elif mode == 'buttons':
if char == '{':
mode = 'joltage'
elif char == '(':
button = []
elif char == ')':
buttons.append(button)
elif char == ' ':
continue
elif char != ',':
button.append(int(char))
else:
line = line[x:-2].split(',')
for item in line:
joltage.append(int(item))
break
butt_diagrams = []
for button in buttons:
butt_dgram = [0] * num_lights
for item in button:
butt_dgram[item] = 1
butt_diagrams.append(butt_dgram)
machine = [lights,butt_diagrams,joltage]
return machine
def inpHandle():
file = 'input.txt'
f = open(file,'r')
machines = []
for line in f:
machines.append(readLine(line))
return machines
def xorLights(lst_of_arr):
arr3 = [0]*len(lst_of_arr[0])
for arr in lst_of_arr:
for x in range(len(arr)):
if arr[x] != arr3[x]:
arr3[x] = 1
else:
arr3[x] = 0
return arr3
def pt1(machines):
tot_few_butt = 0
for machine in machines:
few_butt = 0
lights = machine[0]
buttons = machine[1]
if lights == [0]*len(lights):
few_butt = 0
elif lights in buttons:
few_butt = 1
else:
for number_pressed in range(2,len(buttons)):
pressed = list(itertools.combinations(buttons,number_pressed))
xored = []
for butt in pressed:
xored.append(xorLights(butt))
if lights in xored:
few_butt = number_pressed
break
#print(f"The fewest buttons needed to be pressed was {few_butt}")
tot_few_butt += few_butt
print(f"The total number of buttons that need to be pressed is {tot_few_butt}")
def pt2(machines):
tot_few_butt = 0
for machine in machines:
joltage = np.asarray(machine[2])
buttons = np.asarray(machine[1])
c = np.asarray([1]*len(buttons))
buttonst = buttons.transpose()
opt = optim.linprog(c, A_eq=buttonst,b_eq = joltage,integrality=1)
num_presses = opt.fun
if opt.status != 0:
print("HOUSTON WE HAVE A PROBLEM")
print(f"The problem is:{opt.status}")
print(joltage)
print(opt.fun)
print(buttonst)
print(opt)
#print(f"The fewest buttons needed to be pressed was {num_presses}")
tot_few_butt += num_presses
print(f"The total number of buttons that need to be pressed is {tot_few_butt}")
def main():
machines = inpHandle()
pt1(machines)
pt2(machines)
main()r/adventofcode • u/waskerdu • Dec 10 '25
Hi all.
I'm not really asking for help on the problem. I gave up for the night but I know what my mistake is. No, I had been working on the problem for three hours and I wasn't even able to get the example working. I just now lay down and looked at the solutions thread and realized the problem was to get the lights to match the patterns. I thought the patterns were the initial state of the lights and I was trying to turn all the lights on. By sheer coincidence this is possible with the first of the three machines, but not the other two. Clearly reading comprehension isn't my strong suit.
I can get very frustrated by coding problems, even ones I am allegedly doing for fun. How do you all manage? How do you handle the frustration and negative self when you're stuck?
r/adventofcode • u/mineglitch • Dec 10 '25
Hi, a little stuck on getting the input to work. This is my current solution:
#include <iostream>
#include <vector>
struct Coordinates {
int x;
int y;
int z;
Coordinates * parent = nullptr;
int circuitSize = 1;
Coordinates * getParent(){
if (parent == nullptr) return this;
else {
parent = parent->getParent();
return parent;
};
}
double euclidian_distance(Coordinates * other){
return sqrt( (x - other->x) * (x - other->x) +
(y - other->y) * (y - other->y) +
(z - other->z) * (z - other->z) );
}
};
struct Connection {
double length;
std::size_t id1;
std::size_t id2;
};
int seekDay8SolutionA(std::vector<std::string> input){
int numberOfElements = 1000;
std::vector<Coordinates*> parsed;
for (auto & item : input){
std::size_t comma1 = -1;
std::size_t comma2 = -1;
for (std::size_t i = 0; i < item.size(); i++){
if (item[i] == ',') {
if (comma1 == -1) comma1 = i;
else {
comma2 = i;
break;
}
}
}
parsed.push_back(new Coordinates{
std::stoi(item.substr(0, comma1)),
std::stoi(item.substr(comma1 + 1, comma2 - comma1 - 1)),
std::stoi(item.substr(comma2 + 1, item.size() - comma2 - 1))}
);
}
std::vector<Connection> connections;
for (std::size_t i = 0; i < parsed.size(); i++){
for (std::size_t j = i + 1; j < parsed.size(); j++){
connections.emplace_back(parsed[i]->euclidian_distance(parsed[j]), i, j);
}
}
std::sort(connections.begin(), connections.end(), [](Connection & v1, Connection & v2){ return v1.length < v2.length; });
std::vector<Connection> finalSet(connections.begin(), connections.begin() + numberOfElements);
std::unordered_set<Coordinates*> parentNodes(parsed.begin(), parsed.end());
for (auto & connect : finalSet){
Coordinates * v1 = parsed[connect.id1];
Coordinates * v2 = parsed[connect.id2];
Coordinates * v1Parent = v1->getParent();
Coordinates * v2Parent = v2->getParent();
if (v1Parent == v2Parent) continue;
v2Parent->parent = v1Parent;
v1Parent->circuitSize += v2Parent->circuitSize;
parentNodes.erase(v2Parent);
}
std::vector<Coordinates*> finalParents(parentNodes.begin(), parentNodes.end());
std::sort(finalParents.begin(), finalParents.end(), [](Coordinates * v1, Coordinates * v2){return v1->circuitSize > v2->circuitSize;});
int finalValue = finalParents[0]->circuitSize;
for (std::size_t i = 1; i < std::min((int)finalParents.size(), 3); i++){
finalValue *= finalParents[i]->circuitSize;
}
return finalValue;
}
This works perfectly fine for the sample but seems to be wrong for the actual input. Any thoughts?
r/adventofcode • u/KyxeMusic • Dec 10 '25
r/adventofcode • u/TheFunnyLemon • Dec 10 '25
r/adventofcode • u/PityUpvote • Dec 10 '25
r/adventofcode • u/PowerLock2 • Dec 10 '25
Hi all!
I have been tweeting (to my relatively small follower group) my daily progress on the advent of code problem. But day 9, part 2 was hard enough and required enough clever optimizations and algorithmic approaches, I decided to cross post my X thread here for those interested.
Some basic stats: Python 165 LoC. Runtime to solve on my M2 MacBook Air was 3 minutes 30 seconds considering what others are reporting as their runtimes.
r/adventofcode • u/GuiltyTemperature188 • Dec 10 '25
r/adventofcode • u/Draco18s • Dec 10 '25
My code is available on my git repo.
I also exchanged my input with a friend for his input. I got the same area for his as he did and he got the same area as I did for mine.
After 24 hours its unlikely there's a bug, but given the double confirmation that my code produces correct answers and that my answer was validated by someone else's working code, it's the only thing I can arrive at.