Our great sponsors
-
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.
-
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.
-
AdventOfCode2022
Solutions to all 25 Advent of Code 2022 in Rust 🦀 Less than 100 lines per day, total runtime of less than 1 second. (by AxlLind)
-
advent-of-code-2022
My solutions for the Advent of Code 2022 (adventofcode.com/2022) (by MaxArt2501)
-
advent-of-code-2022
Solutions to Advent of Code 2022 puzzles https://adventofcode.com/2022 (by Lysander6)
-
aoc2022
Trying to solve Advent of Code 2022 in 25 different languages (1 day = 1 language) (by GoldsteinE)
-
Advent_of_Code
A repo revolving around attempting to solve the Advent of Code puzzles with single-statement t-sql (by adimcohen)
-
Advent-Of-Code-2022
My solutions for Advent Of Code 2022. Every day is written in another language, chosen randomly. (by Jomy10)
-
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
Very cool! I wrote day 2 in 6502 assembly and ran it in Vice. I wasn't aware of the llvm-mos simulator. Will definitely play with that soon.
F# - Liked the structure, but part 2 takes around 10 seconds, will work on alternate option after Dec 25
Python 3 44/45
Python (67/88)
python 369 / 1021
Link to full solution
Golang 456/495
Part 1
Golang solution This one wasn't super hard but go is definitely an awkward language to work in for some stuff, and there's not much in the way of speedy idioms to shorten the code. However, the code itself, once compiled, runs very fast and any slowdown I experience is from writing output to the terminal, which part2 doesn't lend itself to considering how wide it gets. Would love another iteration on this where I can put together proper visualizations because this one lends itself nicely to visualization.
Ruby 2010 / 3400
Golang: https://github.com/jasontconnell/advent/blob/master/2022/14/main.go
Here is my really terrible Rust solution to make you feel better about your solution. I really need to write a good grid data structure, surprised i've gone this long without having one.
This reminded me of 2018 day 17, where you had to pour water instead of sand. I also remember making a visualization that year, might as well do it for today's problem too, the code should be almost identical.
My solution was very straight-forward so at first I wasn't really going to post it, but then I realized that might be exactly the reason to post it? Anyway, not much to say about it other than here it is: https://github.com/dclamage/AOC2022/blob/main/day14/src/main.rs
Raku solution: part 1 and part 2.
Perl -- both parts
Rust
40 lines of code
https://github.com/keithn/aoc2022/blob/main/days/Day14.cs
Kotlin: https://github.com/saidaspen/adventofkotlin/blob/main/src/main/kotlin/se/saidaspen/aoc/aoc2022/Day14.kt
Python 3. Full solution
My solution in Haskell. I think I'm just gonna use Megaparsec going forward. Much easier to parse data that way than writing custom functions for it.
Code: https://github.com/jasonincanada/aoc-2022/blob/main/day_14/src/main.rs
JQ
JavaScript / Node.js
Kotlin
Rust🦀 github
It's ugly, but it's mine and it works (Python)
Kotlin: https://github.com/nikolakasev/advent-of-code-kotlin-2022/blob/main/src/Day14.kt
Didn't like my first solution using an array and decided to implement a second one using a set instead. Building the cave could be cleaner but so could the rest.
D
Part 1. This just simulates the falling sand until a unit of sand goes out of bounds, then it stops.
Solution in python using hashable dataclasses part1 and part2
Plese be so gently to add a start on my AoC repo.
Solution (Part 1 & 2)
Solution
Go/Golang solution.
GitHub
So off we go read the input file twice, the first time to get the map boundaries, the second time to setup the bool array : part 1 using 2kB of RAM.
Rust: code
Very interesting. I used a hashmap (data class holding x and y coordinate as key) to keep track of if a position was rock or sand. Then I had a recursive function that found where the sand would land.
Julia simple solution simulating the sand. Too much code duplication but nothing better comes to my mind.
shitty n slow rust solution https://github.com/RHL120/aoc_2022/blob/master/solutions/day14.rs
Part 1 solution.
26 lines of Python. Runs in 1.4s.
Rust targetting 8-bit Atari, with visualization.
This change made my second part runtime faster from 0.65 s to 0.41 s. Seems like iterating anything inside loop makes that loop much slower. Also learned about walrus operator precedence.
Code
Part 1
Typescript Runs part 2 in ~150ms
Rust (~5ms total)
Slow dlang solution that simulates sand drops one grain at a time, one pixel at a time. Here's the main loop for part 2. The occupied[grain] = true assignment is due to the fact that the standard library doesn't have a hashset (to my knowledge), so instead I'm putting Points in an associative array while discarding the values.
Haskell (Probably very inefficient)
C# solution using .NET Interactive and Jupyter Notebook. Used a recursive drop function to simulate a single grain of sand falling. Part 2 is not particularly efficient (~600ms). I went with a brute force approach solving it the same way as Part 1. But saw some clever "ray-casting" methods here in the comments!
Noulith 7/4
Finally got some more time to solve a puzzle. This time in TypeScript. source
With a hash (code):
Scala: github
Solutions to parts 1 and 2 nearly identical and pretty much worked first time. Nothing clever here. This was far simpler than I thought it would be. I probably spent most time trying to think of a mathematical way of getting all points between p1 and p2. In the end, I just constructed two ranges. Full code here.
It's on the initial post: https://github.com/PhunkyBob/adventofcode/blob/master/2022/day_14_visual.py