Given that parts one and two were so similar for this one, I am going to describe them both together. The solution for day seven was all in one function I called try_math . For part one, can_concat was always false; that was an operation introduced in part two. pub fn try_math ( target : i64 , current : i64 , parts : & [ i64 ], can_concat : bool ) -> bool { if parts . len () == 0 { return false ;…
Part One Day six marks the first 2D puzzle for 2024. In this case, the puzzle input represents an environment with sparsely placed walls. There's a guard who walks around, turning right any time he hits a wall but otherwise moving forward. We need to determine how many tiles he covers before leaving the area. Because the movement is deterministic, we only need to store the guard's current…
Part One I'd say this was the first day that needed some planning. We got a list of constraints in the form of X|Y where X and Y are numbers, and X|Y says that in a list, X must come before Y . We were also given many lists that we needed to test against. If a list passes all of the constraints, the middle element of that list is added to a sum. Another was to look at X must come before Y in a…
Part One There always seem to be a lot of 'move around in a grid'- type puzzles with the advent of code, so I spent some time on day four writing some helper functions—simple things like checking if a new coordinate was out of bounds. Once that was done, I read the input line by line. When I encountered an X, I added eight potential search options to a list to be checked in the next step. for line…
Part One I solved day three mostly thanks to regex. For the first part the line: let matcher = Regex::new(r#"mul\(([0-9]+),([0-9]+)\)"#).unwrap(); was matched on the lines in the input. When a match occurred, the capture groups were parsed, multiplied and added to the total. The rules were pretty strict about it being an exact match, so there wasn't any need to compensate for things like…
Part One On day two, we're checking lists of numbers against two rules. First, all numbers need to increase or decrease. Second, the difference between each number and the next must be between one and three. I set up an enum to store the state as I parsed each row. Each row was initially in an Unknown state and became either Increasing or Decreasing after reading the first two values. I kept track…
Part One There is nothing too outlandish here. I expect these posts will need to be longer as the days progress. Naturally, there will be spoilers. We start with a set of numbers separated by three spaces representing two lists. We need to compare elements from the left and right lists to determine the sum of the differences between the elements, starting from the smallest in each list. Parse the…
Over the years I have seen a lot of "this vs that" arguments. React vs Vue, Postgres vs MySQL, Tensorflow vs Pytorch. These debates often lead to zealots who refuse to budge on their position of superiority. More often than not, the differences between these options are minor. Having a good grasp of the fundamentals can help to remove the noise and marketing and allow strong developers to work…
I recently spent time looking at tests in a mature node code base. There are around three thousand across unit and integration tests. Due to the way these tests were written, they can only be run sequentially, leading to a run time of twenty minutes. I spent time migrating the tests so they could run in parallel, bringing the execution time down to under a minute. There are still a handful of…
I work on B2B software in an industry traditionally driven by spreadsheets. We're regularly presented with a need to import data into our system from customers or partners. While we do build integrations, that data is very often spreadsheets. Every time a new need comes up it is tempting to try and 'solve' this problem once and for all. As a younger engineer I would have spent a long time on that…