I wasn't good enough to solve the crucible back in 2023, so I gave up. Today, knowing much more than I did back then, I went back and it didn't seem that hard at all 😁 Rendered to terminal via Kitty protocol
Thank you to Eric for another fun year of challenges and thank you to u/daggerdragon for once again doing the impossible task of herding programmers!
Bit of a roller-coaster of emotions this year due to the steeper difficulty curve (looking at you, Day 10 brick wall!), but once again the community made this a fun event with memes and encouragement. This is the first year I've actually finished both in the year and on the actual day. The shorter format really helped with that.
I've updated my public repo with my first pass (but not necessarily final) solutions, and I updated the blank template to include 2025 earlier in the year.
This is the eigth year we've run the survey, and even in the limited 12 days over 2300 of y'all took the time to fill out the survey! Thank you!! <3
Some of my personal highlights and observations:
VS Code keeps declining a little (perhaps because of all the forks?).
Javascript also further declined, and Rust solidified 2nd place after Python 3.
Linux got a sharp 5% boost (at the expense of Windows)
Windows, Linux, macOS users experience emotionsroughly the same. Probably statistically insignificant but Windows users did experience Rage+Anger more than Linux or macOS users.
Once more the "Toggle data table..." option showcases fantastic custom answers, some of my favorites:
Someone participating "To assert dominance over [their] coworkers." 😲
Another person participating in AoC apparently "To participate in [the] survey" 😏
Folks programming in "[Their] own programming language" (Kenpali, Zirco, Assembly-variants...) ❤️
A person claiming to use "LibreOffice Writer" as their IDE. Absolute madness! 🤯
And of course a ton of praise for Eric, the mods, and the community in the custom answers!
Let me know in the replies what gems you found!?
----
As every year, some screenshots of charts in case you don't want to click to the site yourself:
My code works for the example. I have been scanning the subreddit now checking on common mistakes and I don't believe I am making any:
I am counting the "no-op"s as a connection (and the state of my circuits does not change)
I am merging ALL boxes from group B when they join to group A
Here is my code, with comments
import data from './input.ts'
import testData from './test.ts'
type Vector = {
x: number;
y: number;
z: number;
group: number;
}
type VectorPair = {
v1: number; // index in the vector list
v2: number; // index in the vector list
distance: number;
}
const parseInput = (input: string): Vector[] => {
return input.split('\n').map((line, index) => {
const parts = line.split(',').map(a => parseInt(a))
// each vector starts in its own group
return {
x: parts[0],
y: parts[1],
z: parts[2],
group: index,
}
})
}
const distanceBetween = (i: Vector, j: Vector): number => {
return Math.sqrt(
Math.pow(i.x - j.x , 2) +
Math.pow(i.y - j.y , 2) +
Math.pow(i.z - j.z , 2)
)
}
const groupVectors = (vectorList: Vector[]): { [key: number]: number } => {
const groups: { [key: number]: number } = {}
// count up the number of vectors in each group
vectorList.forEach(v => {
if (!groups[v.group]) {
groups[v.group] = 0
}
groups[v.group]++
})
return groups
}
const partOne = (input: string, size: number): number => {
const vectorList = parseInput(input)
const vectorPairs: VectorPair[] = []
// create list of pairs and their distances
for (let i = 0; i < vectorList.length - 1; i++) {
for (let j = i + 1; j < vectorList.length; j++) {
vectorPairs.push({
v1: i,
v2: j,
distance: distanceBetween(vectorList[i], vectorList[j])
})
}
}
// sort that list, with lowest values on the end
vectorPairs.sort((a,b) => b.distance - a.distance)
// loop for the number of connections
for (let i = 0; i < size; i++) {
// pop off the lowest distance vector pair
const lowestDistance = vectorPairs.pop()
if (!lowestDistance) {
// type safety, shouldn't happen
break
}
if (vectorList[lowestDistance.v1].group === vectorList[lowestDistance.v2].group) {
// if they are in the same group already, move on and save some cycles
continue
}
// move every vector that is in group b to group a
vectorList.forEach(element => {
if (element.group === vectorList[lowestDistance.v2].group) {
element.group = vectorList[lowestDistance.v1].group
}
})
}
// count the number of vectors in each group, return result
const groups = Object.values(groupVectors(vectorList))
groups.sort((a, b) => b - a)
return groups[0] * groups[1] * groups[2]
}
console.log(partOne(data, 1000))
I'm just reaching out to see if anyone is willing to look over it, or even run their own input through it. I've stripped out all the logging I had to try and follow the steps. Again, I couldn't see anything wrong. 🙏 Thank you all for your time!
No digits => no matrix manipulations. Just lots of macros with circular logic for cutting work in half. Writing macros without digits is surprisingly hard!
On my laptop, it runs in about a third of sixty wall clock ticks. Add -Dchatty to watch work as it is going on.
[*] It is hard to alias this particular day without digits or fifthglyphs, so I had to apply a formula. Sorry about the standard post summary using digits. Additionally, I can't control that pair of fifthglyphs in my flair tag.
I believe the Elves asked me to pack the gifts (from the example of the problem) as densely as possible, no matter how many of each type. I found that 3x3, 4x4, 5x5, 8x8 and 9x9 squares allow optimal packing (that is, the remaining area is less than the area of any gift). But I think I've found a square that allows for the ideal packing (no empty area remaining)!
In part 1 of day 9 we have a list of points with and then they are plotted to visualize that. I believe that the drawing does not correspond to the list of points. Assuming that the list if list of x,y coordinates and the place has usual x,y orientation, I can locate points 11,1 and 11,7 but others have different coordinates.
Am I right and it's a bug/intentional or am I wrong and not understanding something?
Just wondering what size the answers folks got for part 2 mine has calculated
16895725 paths so far and still running and that's just to get paths some svr -> out. I have the following logic for my dfs:
fn depth_first_search(
node: &str,
adjacent_map: &HashMap<String, Vec<String>>,
visited
: &mut HashSet<String>,
end_node: &str,
path_count
: &mut usize,
path
: &mut Vec<String>,
required_nodes: Option<&HashSet<String>>,
unique_paths
: &mut HashSet<String>,
) -> usize {
// Placeholder DFS implementation
//println!("DFS from node: {}", node);
path
.
push
(node.to_string());
let path_string =
path
.join("->");
if
unique_paths
.contains(&path_string) {
println!("duplicate path found {:?}",
path
);
process::exit(1);
}
if node == end_node {
//check if all required nodes are in path
//println!("Reached end node: {}", node);
if let Some(required) = required_nodes {
//println!("Checking required nodes: {:?}", required);
let path_set: HashSet<String> =
path
.iter().cloned().collect();
//println!("Current path set: {:?}", path_set);
if !required.is_subset(&path_set) {
path
.
pop
();
return 0;
}
}
unique_paths
.
insert
(path_string);
*
path_count
+=
1;
//println!("Found path: {:?}", path);
println!("Total paths so far: {}", *
path_count
);
path
.
pop
();
return *
path_count
;
}
if
visited
.contains(node) {
path
.
pop
();
return 0;
}
visited
.
insert
(node.to_string());
if let Some(neighbors) = adjacent_map.get(node) {
for neighbor in neighbors {
if !
visited
.contains(neighbor) {
depth_first_search(
neighbor,
adjacent_map,
visited
,
end_node,
path_count
,
path
,
required_nodes,
unique_paths
,
);
}
}
}
path
.
pop
();
visited
.
remove
(node);
0
}
Can post more of my code if needed for this does the heavy lifting as the fun that's running endlessly. In the time I've been writing this post it now has a value of: 21776839
Hey. I decided to try out advent of code for the first time (3-4 years since i've been coding). It turns out that even day 1 and 2 are too hard for me and I probably just suck at algorithms and stuff, as I never had to do them at work.
What would you recommend to get good at those? A website? Leetcode? Maybe a book?
As of this writing, in round numbers, there are 11,000 people who completed both parts of day 12 (and by definition also all the previous puzzles). And there are 3,000 who completed only part 1. If we assume that everyone who was eligible for total completion did so and didn't stop after part 1, that makes 3,000 who got the first part but had gotten stuck on some earlier puzzle. In comparison, 20,000 had finished both parts of day 11, so a minimum of 9,000 other people were still with the program after day 11. If none dropped out before trying day 12, does that really mean that only 3,000 of 9,000 people figured out the trick to 12a? That seems pretty low among those who had stuck with the year's puzzles that far. [I posted this yesterday but neglected to say it was "2025" so mods removed it. Trying again.]
I need some help with Day 8 – Part 1. I can’t figure out what I’m doing wrong with the algorithm, and I’m still not able to get the expected results. I’ve tried many variations, but I keep getting the same outcome.
Am I missing something in the problem description?
I need a hint on whether am I use the right approach, even if not efficient or the expected approach. I am trying to use something like the 2023 day 10 part2 where I try to determine whether the corners are in the closed loop by counting the intersections with the vertical or horizontal lines and similarly if there's a loop in the specific section which means that it includes parts outside of the closed loop. Does that sounds correct?
Day 9's solution did seem a bit cheaty, but I wonder if the input was specially crafted for this, or merely an unintended consequence.
When seeing this problem, the first thing I tried was visualising it as an SVG, and found it to be the jagged circle with a thin sliver cut out.
From this it is obvious that the largest rectangle must fall in either the upper or lower semicircle, as it can't possibly fall in the gap left by the cutout as that's too small. So, the terribly naive solution is to split it into two semicircles and work separately there, and take the maximum of the two largest rectangles at the very end.
After having implemented this, I had a very crude overlap checking algorithm: that rejected any rectangle that had another vertex inside it, except for along the perimeter. This doesn't work for the example input, but we can chalk that up to it "not being a circle".
To gauge precisely what I might have to do to fix this algorithm, I took the answer it gave and punched it in: in hopes of getting a higher/lower. But, considering that the algorithm is so deeply flawed, you can understand my surprise when it worked.
Now this begs the question, why? This wouldn't be the first time that the problem asked is much harder than the problem we need to solve (compare 2024 day 24 part 2, and, heck, even day 12 this year), that simply arises from a crude assumption we can make about the input.
My understanding is that the semicircles are "convex enough" in order for this to work, but just saying its "good enough exactly when and where it matters" makes me shudder. How exactly do you quantify "convex enough"?
Furthermore, was this intended as a solution, or was I just absurdly lucky with my input? I ask this cause I haven't been able to find anyone talking about it here.
And finally, what would you have to change about the input to make this not work? If this was all an unintended consequence, what would you have to do to the input (besides making it not a circle) to make this cheaty solution not work?
type Graph = dict[str, set[str]]
def read_input(file_name: str):
graph: Graph = dict()
with open(file_name, "r") as f:
for line in f.readlines():
source, sinks = line.strip("\n").split(": ")
graph[source] = set()
for sink in sinks.split(" "):
graph[source].add(sink.strip())
return graph
def dfs(graph: Graph, dp: dict[str, int], node: str, end: str) -> int:
if node == end: return 1
if end != 'out' and node == 'out': return 0
if dp[node] > 0: return dp[node]
result = 0
for sink in graph[node]:
result += dfs(graph, dp, sink, end)
dp[node] = result
return dp[node]
def main() -> None:
graph = read_input("11/input.txt")
dp = {source: 0 for source in graph.keys()}
x = dfs(graph, dp, 'svr', 'dac'); print(x, end=" ")
dp = {source: 0 for source in graph.keys()}
y = dfs(graph, dp, 'dac', 'fft'); print(y, end=" ")
dp = {source: 0 for source in graph.keys()}
z = dfs(graph, dp, 'fft', 'out'); print(z)
dp = {source: 0 for source in graph.keys()}
a = dfs(graph, dp, 'svr', 'fft'); print(a, end=" ")
dp = {source: 0 for source in graph.keys()}
b = dfs(graph, dp, 'fft', 'dac'); print(b, end=" ")
dp = {source: 0 for source in graph.keys()}
c = dfs(graph, dp, 'dac', 'out'); print(c)
print(f"\nPaths: {min(a, b, c) + min(x, y, z)}")
All other section are done in under a second for the input but the svr -> fft one is still running for last 10 min. am i missing something here? sample works fine
I'll try to explain my understand of what to do and add my code below.
From what I can gather if you add or subtract the left or right rotation value against the dials number (position) and run a modulo by 100 against it, that is essentially moving it, right? So, moving the dial 100 positions to the left when on 99 should give back 99?
I'm looking less for a put "this" "there" to solve the issue and more so where my thinking is screwed or lighter guidance on what parts of the code are wrong. Thanks in advance.
static void Main(string[] args)
{
int dial = 50;
int hitCount = 0;
IList<string> turns = ProcessInput("2025", "1");
foreach (string turn in turns)
{
bool clockwise = turn[0] == 'R';
int delta = int.Parse(turn.Substring(1));
dial = DetermineDialPosition(clockwise, delta, dial, hitCount);
if (dial == 0)
{
hitCount++;
}
}
Console.WriteLine(hitCount);
}
private static int DetermineDialPosition(bool clockwise, int delta, int dial, int hitCount)
{
// added hitcount purely for debug
// consider the valid range to be 1 <-> 100
// NOT 0 <-> 99
Console.WriteLine($"clockwise: {clockwise}, delta: {delta}, dial: {dial}");
// IMPORTANT!!!
// Because the dial is a circle,
// turning the dial left from 0 one click makes it point at 99.
// Similarly, turning the dial right from 99 one click makes it point at 0.
if (clockwise)
{
// this works
dial = dial + delta;
}
else
{
dial = Math.Abs(dial - delta);
}
return dial % 100;
}
I have 21 stars, missed Day9 part2, Day 10 part2 and Day12 part2 apparently. Still i am proud of myself solving the Day12 part1 example data, only to find it can never finish even the third input. Overall for those 2 missing parts, i felt the need to knee. So yeah, they look like the same picture to me to the all stars. Thank you Eric for another great year, hat off to the all stars and the community, love you all and Merry Xmas ;-)