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.
-
adventofcode
Advent of Code solutions of 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 and 2023 in Scala (by sim642)
-
aoc
My attempts at Advent of Code, along with a smaller helper library to streamline daily AoC tasks. (by hrushikeshrv)
-
advent_of_code
This repository contains my solutions for the Advent of Code programming challenges. (by GabrielTorland)
-
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)
-
AoC2022
I have no time, because I am finishing my master thesis... So this is Python with no other goals than write it quickly. (by Fitli)
-
adventofcode
My solutions for https://adventofcode.com/ programming mini puzzles - written mostly as sjasmplus script (to exercise the tool and collect ideas for future development of the script language, not because it's a best choice for the task, quite opposite) (by ped7g)
-
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
Part 1, 20 lines
TypeScript - was late to party, an answer from Stackoverflow helped to merge ranges.
Not sure if anybody already did this, but I used an integer rotation of 45 degrees to the left to check for the gap of 1 between sensor ranges and then rotated back to the right. Both rotations also multiply everything by a factor of sqrt(2) (for a pure rotation you would divide by that factor but fractional grid coordinates are no good), so to go back to original coordinates you need to divide by 2 in the end. This made the search pretty straightforward. Runs in 26 µs on Apple M1 and 126 µs on Raspberry Pi 4. See at the top of my source code for how I measured that.
Python 3 9/15!!!
Python 3. 1015/169. Quite the jump for part 2, but not quite enough; thanks z3! Full solution
Source: https://github.com/dclamage/AOC2022/blob/main/day15/src/main.rs
Rust (1650/1022)
Elixir 1105/661
Source: https://github.com/PlainSight/adventofcode2022/blob/master/day15/part2.js
Part 1: Although the optimal method of maintaining range endpoints and iterating through them in sorted order was obvious, the bounds were small enough to just go through every point in each range and mark it. Gonna optimize it later code
Ruby 953/408
Language: Python
Typescript (1156/2666)
My Scala solution.
Rust - just collect in range intervals per line. Sum of lengths is basically p1 and p2 is just a loop over rows looking for one with more than one interval. Total runtime for both parts is ~650ms. twitch, youtube.
Rust. This solves both parts for the test + real solutions in about 0.51s on my computer without using any fancy libraries or data structures.
Python solution (<3000)
Code
Full code here
First version: https://github.com/progheal/adventofcode/blob/master/2022/15.cpp
Part 2 ~ 0.574s
Python
Haskell, by far my slowest solution at 6 s.
python3
Pretty happy with today's solutions. Quite compact for Go. https://github.com/ziroc/advent-of-code-2022/blob/main/day15_1/main.go
The same approach as my Python solution — for each row, it tracks the left-most and right-most seen point for each sensor. Then it searches if there has been a gap between two sensors.
This is the code using range utility functions I have in this code. The main ideas are in the blockedInLine(y) function on the S(ignal)B(eacon)Pair and the reduceR(a)ng(e)s function in the utility file.
Github
O(n2) code: [https://github.com/finalchild/advent-of-code-2022/blob/main/15-2.cpp]
Haskell (Realistically only part 1)
Node | JS | Javascript https://github.com/ze-kel/aoc22/blob/main/src/15/index.ts Not clever solution. First we calculate radius around each scanner. From that we can infer a range of values it covers for any Y line. Once we have ranges for each sensor we merge them to remove overlaps.
GitHub
My algorithm is really bad. It tries to scan all y range 0..=4000000 in part2. However my program can solve part2 within 200ms thanks to rayon's parallel iterators and 20 CPU cores.
Rust: https://github.com/chenson2018/advent-of-code/blob/8c5df61380200d5274199ad1a7751c3a87d01f65/2022/15/rust/src/main.rs
I just finished Advent of Code Day 14 and wanted to share my solution. You can find the code (written in Python 3) in my GitHub repo here.
I could optimize my part2 solution to 15.6ms (about 12x faster)
Node.js
TypeScript greedily checking if point is inside some sensor range, kicking from sensor range until finding a point that doesn't belong to any sensor, takes about 3 secs
PHP - source
link
Rust [Github] [Twitter]
Plain rust.
no_std Rust targeting 8-bit 6502: https://github.com/mrk-its/aoc2022/blob/main/day15/src/main.rs It takes 26 hours to complete both parts :]
Zig (Github)
Rust (Naive solution, ~1s)
Both parts nicely solved with SQL Server spatial queries. https://github.com/heder/AoC2022/blob/main/15/15.sql
code
My solution in GO
My solution in Elixir.
Super difficult + hanging out with friends = submitting my solution way too late (Python)
Perl
Quite happy with my solution for part 1, it runs in under a minute on the //c.
Javascript
Rust
Here's my efficient (300ms) Python solution in about 25 lines. I check the outside of each boundary, but not every point. Checking every boundary point takes about 1 min. The trick is that you can skip huge swaths of points because the distance only changes by 2 units at every new boundary point.
Java
Here is an excerpt of part 2: (full code on github )
My C++ solution.
Python
U++ (C++ framework) multi-thread version (or check git history to previous for cleaned-up + fixed single thread variant): https://github.com/ped7g/adventofcode/blob/main/2022-upp/15_beacon_exclusion_zone/15_beacon_exclusion_zone.cpp
[Github](https://github.com/rogisolorzano/aoc-2022-ts/blob/main/src/day-15/index.ts)
Scala 6.5 seconds.
Here's the code with comments if you wanna have a look
Rust
part1, part2
Wow, pretty tricky! Python solution
Fixed my Kotlin solution for part 2 to walk outside the perimeter of the diamonds and find the single point not contained in any of them
Tough one. I cheated with Shapely library in Python. On the upside it finishes in about 1 second. Code here. https://github.com/dsagman/advent-2022/tree/main/day15
I used slower solution to solve part 1, but when I realized it could be this simple, then just rewrote it. Also rewrote part 2 for faster single thread run: github
Solution in Scala (without mutating any variables): github
All my solutions (including 2021): https://github.com/bendiscz/aoc
Rust.