-
Copy paste the equations into a Python script and solve for the maximum/minimum using the Z3 solver, which this time can manage to work in a decent runtime (~30s).
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
-
Java 25/38 https://github.com/fireduck64/adventofcode/blob/master/2021/24/src/Prob.java This involved a recursive sweep through the model number space while memoizing on the current register values. Basically, after the model number parts are read they don't matter for the recursion so the only state is the register values and the execution line number. So the memoization was able to actually help. Although, to be honest my solution for part 1 only worked because the number was near where I started the search (9s on down) and the part 2 only worked because I guessed (correctly) that the first number was still a nine because I'm on to how much Eric likes to punish us. Execution time around 2 minutes.
-
-
"Python", 146/146. Part 1 working out, Part 2 working out
-
advent-of-code-2021
A framework and solutions for Advent of Code 2021 (adventofcode.com) (by dphilipson)
Detailed explanation here
-
adventofcode
Advent of Code solutions of 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 and 2024 in Scala (by sim642)
My Scala manual solution.
-
Python
-
A writeup of my solution
-
Kotlin 171/147 and a more general solution
-
C++ 1276/1333
-
C# 1317/1244
-
"code"
-
Go, 1324/1350. Pure brute force.
-
Python "Precompiled solution" featured on github
-
Wow, my final solution looks almost exactly the same. Though I calculated my initial answers by hand.
-
Rust, Brute Force, < 1min
-
Like so many others, I worked out my answer on "paper"
-
Both Parts
-
my rust solution:
-
Then I wrote a small algorithm which finds the minimum and maximum values: no brute force needed- Full code with extra explanation on github.
-
C++ gitlab
-
I stole today's code, and with colours, because I wanted to work on other stuff. Attribution in the github sources.
-
The solution is manual and well described here. I wrote an AOI simulator and some analysis code in this Go program analyzing the structure of the input and showing some sample simulations. The most interesting output is right at the beginning if you run it where it shows the (very few) differences that each digit's treatment shows - there is no way I would have found the manual solution without the info from that program.
-
Solution First solved this in Excel. Here'a snapshot of the mess. After doing it once, writing code to do it for any input turned out to be surprisingly much easier than I had hoped for.
-
However, I wanted to write code for every problem, that works in the general case, including parsing, so after submitting I wrote some code to do the parsing and choosing the values, in python.
-
So I spend more time analyzing the input calculation. I wrote up that analysis and committed it to my repository, too.
-
TypeScript, Hard day for me, could figure out that instructions are repeating, and line parameters on line 5, 6, and 16 are important and their impact on z, but could not see how it can be used to get min/max number. finally copied solution from u/knl_
-
Brute force with memoization in Scala:
-
Rust
-
-
-
O(1) solution in go (technically you still need to loop through 14 inputs, so this is only O(1) for each input)
-
-
-
Here is the excel file where I worked things out.
-
-
This is in theory a Rust solution: https://github.com/LinAGKar/advent-of-code-2021-rust/blob/main/day24a/src/main.rs, https://github.com/LinAGKar/advent-of-code-2021-rust/blob/main/day24b/src/main.rs. But I haven't actually run it to completion, like everyone else I've analyzed it manually.
-
Python only today.
-
First wrote a short AWK program to convert the input to C and play with it while running a hopeless brute force attempt.
-
-
Clojure (GitHub). In short, I needed some help with the math, but this is one of my favorite solutions I've written so far this AoC. Apart from the fact that algebra in a LISP is pretty messy, I love how merge-with was able to make short work of pruning the search space.
-
-
Nim
-
advent_of_code
This repository contains solutions to each of the problems in Advent of Code 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 and 2024 in C++ (and 2020 in Python as well)
Part 1
-
-
Idris2 - https://github.com/dunhamsteve/aoc2021/blob/master/day24/Main.idr
-
Code: https://github.com/obi1kenobi/advent-of-code-2021/tree/main/day24
-
Go Five and a half days after the problem was posted, I still scored under 10,000.
-
For a full write-up, see this repo, and for a non-annotated solution, see:
-
Here's the code for reference: https://github.com/ManavPenubaku/AdventOfCode2021/blob/main/Julia/src/ArithmeticLogicUnit.jl
-
So I switched tacks and implemented this in Kotlin, where mutation is easier. First version was brute-force with duplicate state avoidance (checked before the state explosion at every input), which worked quickly enough for part 1, but ran into OOMs for part 2. Once I replaced the HashSet with a custom LruSet (and later a simpler CacheSet which simply overwrites on hash collisions) it ran part 2 in a few minutes. I then ported this into Haskell.
-
Here is the recursive function (the heart of the algorithm). Here is the full code with more comments.
-
Solved using MiniZinc, model in day24-1.mzn with the input specified in day24-input.dzn.
-