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.
-
advent-of-code
all my AoC solutions over the years (leaderboard: 66th place in 2022, 53rd place in 2020) (by kwshi)
-
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.
-
Advent-of-Code-2023
My attempt towards solving Advent of Code problem majorly using C++ which is confortable to me. (by eisemsi2)
-
elixiraoc
This is an Elixir project generated with Mix to record my answers of [Advent of Code 2023](https://adventofcode.com/2023)
-
AdventOfCode2023
Coding snippets used to solve the AdventOfCode 2023 in Kotlin - https://adventofcode.com/ (by ToBeHH)
-
advent-of-code-2023
This project contains my solutions to the advent of code 2023 challenge (by Sockalingam29)
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
What you mean by optimal solution? On my machine (i7-12700K, node v21.1.0) your solution runs in ~5ms and my solution runs in ~0.7ms.
Code on Github. My strategy:
Here’s mine for example
GitHub
Link to GitHub
[LANGUAGE: Python 3] 153/75 Raw solution
GitHub
Link to full solution
[code] [embarrassing video]
Code for both parts is here: https://github.com/surgi1/adventofcode/blob/main/2023/day11/script.js
Both parts in a File on GitHub
Fun one :D
Luckily my part 1 solution was similar enough that I didn't need to change a lot to generalize it for part 2. Of course, I did start off by actually adding rows and columns to the image, so that approach had to change. But the way I counted galaxies was the same, so it was a pretty easy thing to amend.
Github
Part 1
20ms both parts https://github.com/Fadi88/AoC/blob/master/2023/day11/code.py
Solution: kAdvent-2023
Part 1 took a bit of fiddling around debugging. I parsed the input into a list of coordinate pairs. I then found the largest X and Y value I could possibly be interested in, and then, for each X value, I checked if the column was clear, and if so, expanded it by adding one to the coordinates of all galaxies with a greater X-value (I spent quite a while trying to find a bug here - turns out that I'd messed up my conditional jump and was instead adding one to the coordinates of all galaxies with a smaller X-value - oops), and then adjusted my loop index and bounds to account for the extra column. I did the same with the Y-value. Finding the pairwise distances was a matter of, for each pair, calculating the taxicab distance. I did some fancy footwork with x86_64's SIMD instructions, doing a packed subtraction of quadwords. Alas, a packed absolute value of quadwords was something that required AVX-512, which my CPU does not support (and, in fact, most CPUs don't support - it's probably a server-tier CPU thing).
Day 11
Code on my GitHub, only 36 lines!
On Github
Code
Solution
part1 : simple implementation - use a hashset to lookup between (x, y) for each pair of points and add to manhattan distance https://github.com/happyhacks/aoc2023-rs/blob/master/day11a/src/main.rs
Part 1
Link : https://github.com/eisemsi2/Advent-of-Code-2023/tree/master/day11
Source Code
Github
Github code
https://github.com/thecae/advent-of-code/blob/main/C/2023/day11.c
See my solution here.
Code
Github
(https://github.com/auno/adventofcode-2023/blob/main/src/day11.rs)
advent-of-code-smalltalk/src/AdventOfCode2023/Day11.class.st at main · jvdsandt/advent-of-code-smalltalk (github.com)
Code here.
GitHub
Day 11 - Github
Github
Github
code here
Here is my solution
From https://www.uiua.org/
code on github
Solution
Not the best solution as it is not fast at all. It also reveals something interesting: in debug mode (cargo test) HashSet is noticeably slower than BTreeSet, but in release mode (cargo test --release) it runs as well, if not slightly better. Code
My solution
Full solution
code
I tried to make my code very short while still keeping it somewhat readable. GitHub
Part 1: Over complicated, does several twists on the map, adding in extra .... lines where needed. Then plots where each galaxy [x,y] is, loop through each against any further galaxies. Simple difference between the x and y cords gives the distance. Sum all together.
Source
While you are correct about the stdlib, check out swift-algorithms (https://github.com/apple/swift-algorithms). It's written by Apple and has several interesting methods.
Full code: https://github.com/JamesTheBard/advent-of-code/blob/main/2023/11/solution.py
So proud to only need to change one variable for Part 2 to work. github
Solution: GitHub
part 1&2 - github
My solution: https://github.com/LinAGKar/advent-of-code-2023-rust/blob/master/day11/src/main.rs. Avoids building up a grid, and also does a single pass over the the galaxies, in each dimension, where it keeps track of the previous total distance. So it's O(n) instead of O(n²).
Functional style: Solution
That felt like a welcome respite
Solution
Solution
OK, this most likely is an inefficient solution. I store the galaxies as a list of [x, y], apply offset to their coordinates one by one depending on how many lines/columns with smaller indexes there are, then use itertools.combinations to find pairs and finally calculate Manhattan distances between the pairs. That's a lot of overhead that includes over 100 000 pairs in the combinations iterator, though it works pretty quickly.
code
Such a relief after yesterday's (and today's) hell with day 10 part 2! All nice and tight: https://github.com/cainkellye/advent_of_code/blob/main/src/y2023/day11.rs
Github
Code