Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
adventofcode
Advent of Code solutions of 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 and 2023 in Scala (by sim642)
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
AdventOfCode
Hacky solutions for [Advent of Code](https://adventofcode.com), working on past problems (by AllanTaylor314)
-
Advent-of-Code-2021
Made it through all 25 days of Advent of Code for the second time! (by Leftfish)
-
advent-of-code-2021
My solutions for the https://adventofcode.com puzzles (2021) 🎄🎅 (by ClouddJR)
-
advent-of-code-go
All 8 years of adventofcode.com solutions in Go/Golang; 2015 2016 2017 2018 2019 2020 2021 2022
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
(Here's my original version that used the uint64 encoding: https://github.com/danvk/aoc2021/blob/e795c78090c35c0b9880fd692ba1677fae31e044/day23/day23.go)
Python, 407/8. Part 1, Part 2, Part 2 cleaned up. How did y'all do part 1 so quick?
Link to full solution
My Scala solution. (to be cleaned up/optimized)
Source at submission time
Part 1, which only worked for rooms holding two amphipods, then Part 1&2 that works for (theoretically) any sized room. Takes less than 5 seconds to solve both parts.
2119/1075 Python
My solution to part 1 in Python: https://github.com/kupuguy/aoc2021/blob/main/src/day23-1.py and part 2 is: https://github.com/kupuguy/aoc2021/blob/main/src/day23.py
1419/1994 C#: GitHub link
C# Solution (one of the less nice-looking ones even after cleanup)
python incomplete
Javascript, 34/2223
I likes today's problem. Part 1 solved by hand. Part 2
my rust solution - runs in ~650ms. All it does is explore all possible move sequences that obey game rules. Ordered by increasing total cost.
GitHub. This is a parallelized brute-force algorithm that plays through every possible move, collects the scores of the winners, then displays the lowest of the scores.
C# CSharp
Today was insane for me. Basically spent like 10 hours working on it, but I started from scratch in the last hour and got both parts. I made very stupid mistakes such as reversing the values when reading them or writing a 2 instead of a 3. I am tired, but we are almost at the end! Part1 and part2 in Javascript.
Rust solution
[Python3](https://github.com/aribchowdhury/AdventOfCode2021/blob/master/day23/code.py)
Full code https://github.com/Matsemann/algorithm-problems/blob/main/adventofcode2021/src/main/kotlin/com/matsemann/adventofcode2021/Day23.kt
TypeScript, Very slow, takes around 20 sec to solve part 2, but readable code, DFS with string as state, The Room type helped to optimize some code. Tried optimizing based on other solutions, but no luck. Reminded me of day 11 from 2016. Will try F#, which may be provide faster string processing with SPAN.
My code is super slow: takes about 15 minutes for part 2. There is much too improve: will take a good look at this after the 25th.
https://github.com/1e9y/adventofcode/blob/main/2021/day23/day23.go
Python - needs over 45 seconds but WORKS, which is good enough for me after a couple of days, especially given the fact that I can spend at most 1-2 hours a day solving this... The ugliest part are probably the hard-coded distances from rooms to corridors and vice versa, but what the heck, it works.
Dijkstra algorithm, relatively fast and readable. Source
Elixir
Go/Golang solutions
Raku and Go because the Raku implementation took tens of minutes to get a slightly-too-high answer, so I figured it would be easier to iterate on bug fixing in a language that could get a wrong answer in seconds. After a couple days of occasional work and a very tedious Go test case that demonstrated my move logic was correct, I realized that my bug was in discarding board states if I'd seen them show up before, even if the new one came at a lower total cost. For example, inefficiently moving As into position before moving D in would produce a high-cost solved board faster than moving the D first and then efficiently moving the As. By changing my seen set to a map of board state to cost, my code suddenly worked.
Nim with my walkthrough here. Similar to the other solutions, just brute-forcing all possible moves for Dijkstra's algorithm. My walkthrough simply explains how to figure out the valid moves to do so, turns out it isn't too hard after having written it down (and simplifying my code).
Haskell 1171/339