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.
-
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
Advent of Code solutions of 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 and 2023 in Scala (by sim642)
-
Advent-of-Code
Discontinued My solutions for Advent of Code challenges - https://adventofcode.com/ (by vaithak)
-
adventOfCode
Advent of code solutions, probably mostly in C++, but maybe in Rust in the (near) future. (by osalbahr)
-
AdventOfCode
Hacky solutions for [Advent of Code](https://adventofcode.com), working on past problems (by AllanTaylor314)
-
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)
-
ultimatepp
U++ is a C++ cross-platform rapid application development framework focused on programmer's productivity. It includes a set of libraries (GUI, SQL, Network etc.), and integrated development environment (TheIDE).
-
advent-of-code-2022
My solutions for the https://adventofcode.com puzzles (2022) ππ (by ClouddJR)
-
aoc2022
Trying to solve Advent of Code 2022 in 25 different languages (1 day = 1 language) (by GoldsteinE)
-
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-2022
Joel Eisner's completed TypeScript code challenges for "Advent of Code" 2022 (by joeleisner)
-
AdventOfCode2022
Repository for advent of code code to find solutions. This year in Go. (by BlaximusIV)
-
AdventOfCode-Day9-RopeBridge
C# console app that solves the AdventOfCode Day 9's puzzle - RopeBridge
-
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
TypeScript - Under 60 lines of code, well typed, single function to solve both parts
Readable Javascript solution, You can look for index.js where i solved it for the first time, compare that with solution on readable.js , readability matters
It took me very long in part 2 to realise that I had to take one step at a time for every knot. I had built it to move Head all the way, then move Knot1 all the way to Head, then move Knot2 all the way to Knot1, etc. That this was wrong WAS visible in the result of example 2, but my method gave the same answer 36 and it had only ONE different visited location on the whole grid, which I totally missed. Gah. Source: https://github.com/ednl/aoc2022/blob/main/09.c
I recommend SIMD2βit can save you a lot of reinventing the 2D wheel!
Python, 114/34. Video coming soon, part 1 code, part 2 code.
Anyway, this still needs more cleanup but here's cleaned up code (rather than the raw original solutions linked above).
Python, 328/89. Code for both parts
I present both a lightly cleaned up solution written while leaderboarding and a much more reasonable post-leaderboard version.
Some premade utils came useful: Point class, Direction class, Point.move(Direction) method, and Point.getAdjacent(). Source for them here: https://github.com/Nohus/AdventofCode2022/blob/master/src/main/kotlin/utils/Geometry.kt
Github
Rust / Recording
Github link to my solution I hard coded all the possible moves for a knot in a lookup table, but I've since realized that it could have been simplified to some relatively simple logic
Source
My Scala solution.
Kotlin Day 09 The tail chasing a head by moving based on the result of compareTo helped trivialize this one ... rope[parentIndex + 1] = Location( x = child.x + parent.x.compareTo(child.x), y = child.y + parent.y.compareTo(child.y), ) ...
Python3 readable solution: GitHub link: https://github.com/vaithak/Advent-of-Code/blob/main/2022/Day-9/code.py
Haskell. My idea for part 1 was basically "Find all the places the head goes, then follow it with the tail" which ended up working basically for free in part 2, and I chose the lazy implementation of "just compose these functions together manually, its what the language was built for". Definitely going to refactor that part in the morning lol
[Source Code](https://github.com/MartinSeeler/advent-of-code-next/blob/main/puzzles/09/solution.ts) | [Run Online](https://advent-of-code-next.vercel.app/day-09-rope-bridge)
Good thing I prepared a Vector data structure after yesterday's puzzle, came in handy today, and probably will in later days too.
Scala: Parts 1 and 2
Rust (https://github.com/cdkrot/aoc-2022-rs/blob/master/src/day09.rs) I think itβs nice and short ``` use std::collections::BTreeSet; use crate::utils;
Part 1
Part 1 starts by parsing the input. I first count how many steps there are (e.g. "R 4" is 4 steps). Then, after allocating an array to hold those steps, I read in the steps and expanded repeats.
Python (original for part 1, part 2, then a general version), then Google Sheets (the first attempt crashed the spreadsheet - Whoops!)
Julia without black magic.
- About 60ms on my system - tuples for the indices, and simple math to update knot position solution
Python [code](https://github.com/mrbaozi/aoc/blob/main/2022/day09/day09.py)
Python (3.10) Solution, I'm pretty happy with how it turned out. Need to get rid of the CoordDict stuff which was intended for possible pt 2 needs but can be replaced by a simple set. Git Link
Elixir 8358/5877, code, path ascii art
Today's solution in Elixir. I first wrote a Python solution to figure out what I generally wanted to write.
U++ (C++ framework): https://github.com/ped7g/adventofcode/blob/main/2022-upp/09_rope_bridge/09_rope_bridge.cpp
U++ (C++ framework): https://github.com/ped7g/adventofcode/blob/main/2022-upp/09_rope_bridge/09_rope_bridge.cpp
Code lives here and I scheduled a [blog post here](rope-bridge-solving-advent-of-code).
Scalable Python solution in <40 lines of code (excluding comment lines!) https://github.com/gmorinan/advent-of-code-2022-simple-python/blob/main/day09/day09.py
Code on GiuHub: Here
Day 9 - Rust
ELIXIR
Quite fun, I had around exactly the same code as you, which I refactored to https://github.com/Sh4d1/aoc2022/blob/main/src/day9.rs
Typescript
Java Github Commit
Clojure
Github
github
Python: https://github.com/davearussell/advent2022/blob/master/day09/solve.py
Had part 1 almost first try, and then struggled a bit understanding part 2 correctly. Once I did, it wasn't too bad to adjust what I had to work with any number of knots, only thing that tripped me up for a bit was that I was missing the outer corners for "updateTail" as they can't happen in part 1, but will happen in part 2.
C# Solution
I'm doing different language each day, all solutions here.
the first part took me more time then I am willing to admit but here is the central idea of my class based solution. more in the repo
golang solutions
Github
link
A couple of variations done in Scala 3 today.
Donβt seem too many Ruby solutions: github
Scala. Not too bad with my Point helper class. After part 1 I refactored the movements into a move helper that just takes 2 arbitrary points; the current point and the one we are moving towards. Then it was easy enough to just apply that in order each iteration for part 2.
I have created custom Rope class to move the knots and made use of the built-in class Point and its methods `fourNeighbours` and `eightNeighbours`.
Day 9 in Swift
- [Part 1](https://github.com/rogue-kitten/aoc-22/blob/main/Days/Day9/part1.cpp)
PYTHON A solution that leverages a lot the itertools library
Python
Yeah, I had the same problem with the hash function. I gave up and cheated by turning my coordinate into a std::string βx,yβ and storing that in the set. (Line 55 - https://github.com/MicahSpikah/advent-of-code-2022/blob/main/9b.cpp)
25 days in 25 languages
PHP# github
Part 1 & 2
My Rust solution, pretty happy with the update function...
Never had part 2 done some quickly after part one, `iterate` is amazing! Haskell
C++ github
PHP: https://github.com/a-ghigi/AoC_2022/tree/main/09
It ain't pretty, but PHP: https://github.com/dsamojlenko/advent-of-code-2022/tree/main/day09
It's not pretty, but it's mine.
Rust. Pretty clean solution with elegant use of constant generics: https://github.com/AlexanderNenninger/AoC2022/blob/master/src/days/day09.rs
github
My solution
Once I figured out how to elegantly move the tail using signum() in part 2 it became so much cleaner. Full code is on GitHub, but here's the core of it:
Python
Short solution using custom Coordinates class.
Python3
Github
Swift
Github Link
github
Code on GitHub (includes unit test)
Another Ruby solution. https://github.com/JeffreyMPrice/adventofcode/blob/main/day09/day09.rb
Mine in rust too is there: https://github.com/Philippe-Cholet/rusty-aoc/blob/main/aoc2022/day09/src/lib.rs
TypeScript this one was by far the hardest for me, i had to take a break after seeing part two but im pretty proud of my solution
Github
Full Code
Python solution
Rust | Github
Rust: GitHub
Dlang bruteforce solution. For some reason I thought the rope was 9 knots long and kept getting off by one results. Relevant part 2 portion :
Still, here's the BASIC code (part 1 only) that runs very veeeeery slowly on the //c, but mostly, I'm quite happy about the fast one in C ! (both parts using #define N_KNOTS)
GitHub link
With the solution to part 2 being similar. Full source code here https://github.com/dionysus-oss/advent-of-code-2022/tree/main/day-9 and a video which goes into detail about how the solution works https://youtu.be/6eqUvtcChWs
My solution is in Go. Still learning the language so if you have any tips or tricks to clean my code and make it more idiomatic, I'd love to hear them!
Would you be able to test https://github.com/joatca/adventofcode/blob/main/2022/9.cr on the same hardware?
Repo!!
Github
Concise solution, ~50 lines.
Full code here: https://github.com/randyppa/AdventOfCode/blob/main/2022/day9.py
My Python solution reproduced below. Used numpy just to make math on coordinates less cumbersome.
Here's mine! https://github.com/SolarBear/AdventOfCode2022/blob/main/day9.rb
rust, took a bit to settle on this one. i don't hate it. uses a const generic for rope length
python/jupyter
my crystal solution runs in 25ms
Code: day9.py
Solution in go: day09.go
Python Code
Not super happy about this solution, but it worked
Tiny little thing you could do to make this even more succinct: Use `abs()` on `dx` and `dy`, that's what I did!
If somebody wants to laugh, check my poor only part 1 solution on my GitHub.
Full Code
github repo for this day
code
can someone help me figure out what's wrong with my c++ code.
Github
The core of my solution below using numpy (because I'm learning it!). See github for full code.
Another Java Solution link
Code 9a
did it but the code is spaghetti - https://github.com/Jelly-Pudding/advent-code/tree/main/day9
I'm late and trying to speed through it all. Using Python, link to repo