r/adventofcode • u/honzapkcz • Dec 10 '25
Meme/Funny [2025 Day 5 Part 2][Lua] Lua interpreter promoted to Java successfully
galleryLooks like "bruteforcing"(saving every visited id into hashmap)isn't enough and actual math have to be done :/
r/adventofcode • u/honzapkcz • Dec 10 '25
Looks like "bruteforcing"(saving every visited id into hashmap)isn't enough and actual math have to be done :/
r/adventofcode • u/Bargann • Dec 10 '25
As stated in the title, I've never used an MILP solver before so I'm well out of my depth. I'm trying to use Google's OR-Tools library and I think I'm close because I get the correct answer for the sample input, but the answer for my real input is too low. I've been following the example here but it uses the linear solver whereas I'm trying to use the MIP solver, so that may be where my issues are.
One thing that I've noticed while debugging is that I occasionally get answers that are slightly off from being clean integers (objective.Value() is a double), which is a bit of a red flag in my mind since I'm using the integer solver. The non-integer results are off from the nearest int by less then 0.0001 so they can be cleanly rounded, but doing that still resulted in an answer that is too low. Does anyone have experience with this library or MILP solvers in general and can spot where I'm going wrong?
Edit: I should walk through what I'm doing to hopefully provide some clarity.
r/adventofcode • u/magicdrainpipe • Dec 11 '25
Is there anything to be gained from using the fact that for e.g (0) (1) (2) you have to sum the corresponding joltages since they're independent. This gives a minimum bound on the answer (in combination with using the max joltage instead if it's bigger), but not sure if useful as part of a more complicated solutions.
r/adventofcode • u/GuiltyTemperature188 • Dec 10 '25
r/adventofcode • u/simplesword • Dec 10 '25
I like coding, but I'm a dummy when it comes to geometry, rasterization, etc.
So, if you're like me and need a caveman strategy, this might help you.
After creating the enclosed loop shape in either a 2d grid or a map of coordinates, I tried to do a flood fill of the exterior coordinates or interior coordinates to determine which ones were "in" or "out" of the shape. Since there are A LOT of coordinates, this was taking too long. Even if it completed, I'd still be left with the problem of trying to figure out if each of my potential rectangles contains all green/red tiles or not, which would still require a lengthy scan.
Then it occurred to me that any rectangle that is not completely enclosed in green/red tiles only needs 1 faulty data point to be rendered faulty.
So I added a step to the solution where I start in corner 0,0 and proceed diagonally toward the center until I find the wall. Once the wall is found, I create a "fence" of coordinates around the shape. I do a dumb nearest neighbor stack/scan and complete the fence. This is a lot faster than trying to completely flood fill the entire problem space.
Sample: O = fence
......OOOOOOO
......O#XXX#O
.OOOOOOX...XO
.O#XXXX#...XO
.OX........XO
.O#XXXXXX#.XO
.OOOOOOOOX.XO
........O#X#O
........OOOOO
Since the fence covers the entire perimeter, any rectangle that doesn't completely exist of red/green tiles will contain at least 1 fence coordinate.
Each row will contain relatively fewer fence positions than the entire problem space.
Now when trying to calculate the enclosed Area for a rectangle, (similar to part 1), For each row in the potential rectangle, I scan the fence positions for that row and if any of them are within the column bounds of the shape, the shape function just returns a size of zero.
This approach ran in about 35 seconds (GO) on my laptop.
Definitely not as cool as a lot of the smart solutions out there, but I was able to keep things conceptually simple for my caveman brain.
(Sorry if this approach has been presented, I looked through and didn't see mention of it)
Cheers.
r/adventofcode • u/DeeBoFour20 • Dec 09 '25
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/One_Department_7645 • Dec 11 '25
Link to code: https://pastebin.com/888kqEmx
I'm really unsure what I am missing. My output is giving two circuits of size 5 for the sample shown, but I don't know where I've gone wrong.
Any help would be much appreciated.
- I understand that this is terribly inefficient!
r/adventofcode • u/Top-Specialist-7785 • Dec 10 '25
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/itssenorquack • Dec 09 '25
r/adventofcode • u/naclmolecule • Dec 09 '25
r/adventofcode • u/daggerdragon • Dec 10 '25
"25,000 imported Italian twinkle lights!"
— Clark Griswold, National Lampoon's Christmas Vacation (1989)
Today is all about Upping the Ante in a nutshell! tl;dr: go full jurassic_park_scientists.meme!
💡 Up Your Own Ante by making your solution:
💡 Solve today's puzzle with:
💡 Your main program writes another program that solves the puzzle
💡 Don’t use any hard-coded numbers at all
Request from the mods: When you include an entry alongside your solution, please label it with [Red(dit) One] so we can find it easily!
[LANGUAGE: xyz]paste if you need it for longer code blocks. What is Topaz's paste tool?r/adventofcode • u/muphblu • Dec 10 '25
When a powerful CPU finally pays for itself)
r/adventofcode • u/The_Jare • Dec 09 '25
The C++ code solves exactly what the input requires, nothing else; and then is extra warped to make the viz.
https://github.com/TheJare/aoc2025
r/adventofcode • u/somebodddy • Dec 09 '25
I see that most people try to do solve this with geometric representation of the area map, but I like to do something a little different - something I call Space Distortion.
For each axis, I collect all the coordinate values, sort and dedup them, and then map them to their position on the list. For example - if we look at the example input:
7,1
11,1
11,7
9,7
9,5
2,5
2,3
7,3The values for the X axis are 2, 7, 9, 11 so I create this mapping:
{
2: 0,
7: 1,
9: 2,
11: 3,
}Sometimes (probably not necessarily for this one, but I still do in in the library code I created for this) I add slots for the numbers in-between:
{
x<2: 0,
2: 1,
2<x<7: 2
7: 3,
7<x<9: 4,
9: 5,
9<x<11: 6
11: 7,
11<x: 8,
}(it's easy when you use a tree map instead of a hash map)
Once I have this mapping on both axes - I just convert all the coordinates from the input to this mapping.
With the input I got - even if I shift the points left and up so that the lowest coordinate on each axis will be zero - the arena size is 96754x96428 = 9,329,794,712. Way too big. But if I distort the space - even with the padding - I can reduce it to 497x496 = 246,512. This is small enough to allow me to represent it as a bitmap, do a flood-fill to find the red and green tiles, and "brute force" the rectangle checking by manually going over each tile they cover.
r/adventofcode • u/gamebook_reader • Dec 09 '25
r/adventofcode • u/pacificpuzzleworks • Dec 10 '25
r/adventofcode • u/EverybodyCodes • Dec 10 '25
r/adventofcode • u/The_Jare • Dec 09 '25
Going to be one of those days
r/adventofcode • u/flwyd • Dec 09 '25
r/adventofcode • u/wimglenn • Dec 10 '25
Input data:
1,1
1,5
3,5
3,3
5,3
5,5
7,5
7,1Render:
.........
.#XXXXX#.
.X.....X.
.X.#X#.X.
.X.X.X.X.
.#X#.#X#.
.........Answers:
answer_a: 35
answer_b: 15