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
My Advent of Code solutions. I also upload videos of my solves: https://www.youtube.com/channel/UCuWLIm0l4sDpEe28t41WITA
-
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.
-
aoc-2021
My Solutions to Advent of Code 2021 ( https://adventofcode.com/ ). I don't know which languages i'll use yet, probably some C, some Rust, some Python and maybe some C++ (by CaptainJack42)
-
advent-of-code-2021
Repository of my https://adventofcode.com/ solutions for 2021. (by Nathan-Furnal)
-
AOC2021
Discontinued My Haskell solutions for the 2021 edition of the Advent of Code (by MatthiasCoppens)
-
advent-of-code-2021
Discontinued Code I used for solving https://adventofcode.com/2021 (by pavel1269)
-
gifski
GIF encoder based on libimagequant (pngquant). Squeezes maximum possible quality from the awful GIF format. (by ImageOptim)
-
adventofcode
My collection of Advent of Code solutions in a slightly overkill project setup 🙃👻 (by marcelblijleven)
-
AdventOfCode2021
Advent of Code 2021 challenge: 13 different languages, one chosen at random every day! (by Qualia91)
-
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
Oh also lost about 2-3 minutes on part A initially trying to use my challenge.TileMap so I didn't have to worry about computing x/y but converting to/from rune all the time was taking way too long and was hard to follow. Man, I can't wait until generics!
Raku 4487/4395. While reading the problem description I though "Cool, after implementing diagonals twice when I shouldn't have, this one wants diagonals." Then I copied my neighbors function from day 8 and didn't include diagonals :-) Didn't waste too much time to spot that one, though my attempt at a fancy version involving set operations led me to once again question the semantics of Raku sets.
F# First time in 11 days, used a mutable variable to keep the counter, any pointers to remove the mutations will be helpful.
2/2! Best day so far! Python. Video of me solving.
rust part 1 and 2
Code Here
Github Code
Python (1119/999)
Perl 754/924 First day in under-1000 zone :) Pretty straightforward code.
Rust, not my proudest code, honestly quite messy, I couldn't decide whether to represent points as Vector2 or usizes into a vector, using both a HashSet for flashed but a Vec for to_flash feels silly, especially since it calls contains on both in the same condition, nor am I proud of the rightward drift resulting in five layers of braces, and the messy conditions on neighbor. But nonetheless, it works, and part 2 was easy enough to hack in on top of part 1, with a couple extra lines (albeit, still a bit messy, with a range 0..usize::MAX since bounded and unbounded ranges are different types, and an unreachable!() in the match statement at the end).
Python runs in 51.7ms
Was able to get it done quickly, but it's messy and not very efficient. I've cleaned it up a little bit, but I'll probably re-examine and refactor in the morning. Fun problem though!
C++ 1531/1488. Code on Github.
Part 1, Part 2
Java
Solution + tests
Python I tried to vectorize as much as I could:
Python: https://github.com/ricardofitas/Advent-of-code-2021/blob/main/Day11_AoC.py
Day11
Rust, tried avoiding the overflow ifs as on Day 9.
Golang - https://github.com/jollyjerr/advent-of-code/blob/main/2021/day11/main.go This problem was rad! I used an adjacency list with breadth-first search for the flashes
Lamest Python code you've ever seen
Rust. I was pretty happy with how my code turned out for this one after I took the time to refactor. Though, I wish the recursive solution for this (and day 9) was easier to write in Rust.
F# in Jupyter Notebook. Decided to go with an infinite sequence (generator pattern) for the steps. This made Part 2 a breeze!
Github Link
Ruby - https://github.com/dhruvasagar/comp/blob/master/adventofcode/2021/day11/day11.rb
Part 1 & 2 Solution
My golang solution. First time i tried recursive closure in Golang and I love it ❤️
Typescript, as per usual from me
Problem is easy with array manipulation functions and adding an "edge" around the map : https://github.com/mariush-github/adventofcode2021/blob/main/11.php
Python 3, nothing much to say. I'd like to find something nicer for applying patches like +1 to all adjacent positions...
Kotlin, Python, Rust follow a similar pattern, although I'm using Option in Rust, so the sentinel is None instead of -1 (which wouldn't be a u32).
Python 3- found that this was front-loaded in terms of difficulty; the initial work on the small grid worked fine, but I needed to keep track of the octopuses that had flashed, which meant on the large test it wasn't working properly after a few steps. Once I'd done this and repeated the 'flash check' until no octopus flashed, then it worked pretty well.
Using a HashMap for the octopuses instead of a 2D array worked pretty well together with helper functions from my Coordinates class.
Koto
Full code
Wow, this is remarkably similar to what I ended up with: https://github.com/agersant/advent-of-code-2021/blob/main/src/day11.rs
Solution in Python using numpy array as grid.
PHP
This instantly reminded me of cellular automata and firefly synchronization haha but I solved it in python with relative ease!
I've put my updated version on github if you want to take a look :)
Scala Could reuse a lot from two days ago. The relevant parts:
I did with recursion too, but to make a point flash it must have exactly value 10. So I just need to edit all numbers that have value over 9 to a zero at the end. Don't know if its any faster :D My Python solution using external library Numpy
GitHub/DumboOctopi.java
Rust Solution using a Hashmap for the octopuses and a queue to keep track of flashes.
Day 11 code here.
Code
Rust
Julia
python using recursion and a set to remember the positions.
I feel like today's problem challenged my reading comprehension. code on github
Julia (both parts)
Python3:
Python3
GitHub link - recursive flash with a global variable
Nice, my solution (also Py3) is very similar but using iteration with a queue instead of recursion
COBOL
Scala using a LazyList
Haskell, runs in about 160 ms.
Python day 11 using convolution
part1 and 2
Not really happy with this implementation, tbh. (Source and tests)
JavaScript part 1 and part 2
Ruby, pretty straightforward, created a hash for the octopus state, giving each octopus data on its coordinates, its flash counter, and whether it flashed on the current turn, then did flashing recursively.
Python 3.9
F# [Solution]
Surprised at the pretty small input file size :D but pretty easy Python solution using dicts, lists, and sets. Python comprehensions just make life so much easier.
With memory optimized tables and types, and a natively compiled stored procedure. Also made a solution with an old fashioned procedure here. Both are very slow...
Messy solutions that earned 242 and 287 (40 and 45 lines respectively).
SQL
Kotlin solution (part 1 and part 2 merged)
The p1 and p2 functions are super concise after creating the OctopusCavern object to do the heavy lifting. https://github.com/joeyemerson/aoc/blob/main/2021/11-dumbo-octopus/solution.js
Today's solution in Common LISP.
Simple Python Solution, easy to understand: Both Part 1 and 2
github
Python Solution
Enjoy my Python solution.
All my solutions here
My vanilla JS (esm) solution https://github.com/thezanke/adventofcode-solutions-js/blob/main/2021/day11/day11.js
part2
Part 1 and 2 Using Recursion
Good old PHP
Erlang, 100 Octopi talking in parallell! https://github.com/tobega/aoc2021/tree/main/day11
I fought the Rust compiler so much today. I wanted to go about it in a different way utilizing a struct which called various helper methods. I kept running issues of borrowing in a loop and passing around mutables. So I rewrote it to stop using Vec> which was my first win and made the rest easier with vec method chains: https://github.com/McSick/AdventOfCode2021/blob/main/11/octo-lights/src/main.rs
As always, I'd love feedback! https://github.com/tallbikeguy/advent-of-code/blob/main/2021/advent11.lisp
Here is the code I used to create the animation: https://github.com/Finomnis/AdventOfCode2021/blob/main/src/renderers/day11.rs
With gifsky. It's both a binary and library crate for the creation of high-quality gifs.
Clojure
Here is the code in Rust: https://github.com/debuti/advent-of-rust-2021/tree/main/dec11th
Gitlab
My solution in Python. It's astonishing how much trouble I had today despite my experience with cellular automata.Lots of off-by-one errors and problems with synchronicity.
Here's my solution for both parts in Racket.
My solution in C#: GitHub
These are the key functions. The whole code is on GitHub
Python Part 2: Github
I suppose Dyalog Extended can be used as a convenient library for AOC. It allows the j-style method of specifying an array of repeats for ⍣.
No. It's just here, as part of my Advent of Code repository.
kotlin solution -- I don't know what it is about Conway's GoL, but I always screw up the logic enough to be a problem but never badly enough that I can actually spot the problem haha
See https://github.com/timvisee/advent-of-code-2021/blob/master/runner/src/bin/bench.rs
Simple solution in Clojure.