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
Hacky solutions for [Advent of Code](https://adventofcode.com), working on past problems (by AllanTaylor314)
-
advent-of-code-2023
About Solutions for Advent of Code 2023, written in JavaScript using node.js (by johnbeech)
-
aoc-2023
Discontinued My Advent of Code 2023 Solutions [Moved to: https://github.com/AJMansfield/aoc] (by AJMansfield)
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
Hm, thinking about it I think I actually have something coded up in my lib.math module which would apply here. Take a look at chinese_remainder_incongruence or offset_chinese_remainder_incongruence (which delegates to the former but accepts a slightly different set of expressions that make more sense in my head.) Obviously converting the cycles to all the incongruencies is absurd, but the first step in my algorithm is converting to candidate valid congruencies which does match this problem well.
Sorry for the late response. The key is to also use await on the first part. I created a gist so you can have a look. The bench function I wrote is here in case you need it.
Can check it here: https://github.com/vorber/AOC2023/blob/main/src/day8/Program.fs
Busy day today, going back to sleep zzZZZ. Clean solution and walkthrough here later today (hopefully).
Repository
repo-folder
Edit: Made some of those improvements. Have a look at main. Want the original code? Check out commit c6ae21b
[LANGUAGE: TypeScript] 2364/1313 github
Probably could've gone about it in a smarter way but here you go https://github.com/Zeus432/AdventOfCode/blob/main/2023/8.py
combined/part1/part2
https://github.com/surgi1/adventofcode/blob/main/2023/day8/script.js (both parts, run in browser)
Started off by just trying brute force for part 2. But I figured it would not go so well, given the emphasis on "significantly more steps". So I went back and verified, and all of the paths are actually cycles :)
Day 8 in Swift
Code
here is my solution. https://github.com/snowe2010/advent-of-code/blob/master/ruby_aoc/2023/day08/day08.rb
github
[LANGUAGE: Rust] https://github.com/Ununoctium117/aoc2023/blob/main/day8/src/main.rs
Day 8
Part1 runs in 1.5s, part2 - 7s https://github.com/Aigul9/AdventOfCode/blob/master/year2023/Day_08/main.py
Link, Language
Link, Language
on Github
GitHub
Github
my github - both p1 and p2
My ugly solution
GitHub 1, 2
Part 1 was implemented pretty much following the problem statement - I chose to represent the map using a dense data structure (since, after all, RAM is cheap enough that I can ask for 26^3 * 4 bytes (~70kib) just because). I parsed the instructions and the map, but I found I couldn't zero-terminate my instructions, since I was representing left as zero and right as two (since these were actually memory offsets). I thus used 0xff - something the fullptr folks might appreciate. The map was parsed as follows - I treated each node as a base26 integer, where the first is an index into an array of pairs of words, and each word is the index that the left and right nodes lead to.
Source code in GitHub.
[github]
Part - 1
Code
[LANGUAGE: Golang] Go Dart
[Language: Rust] GitHub
[Language: Rust] GitHub
Code
[LANGUAGE: rust] todays code
Kinda proud of the way how I've made both parts work with the same function. JavaScript - AoC 2023 - Day 8 - Part 1 + 2
[ Language : Javascript ] Code : https://github.com/sanishchirayath1/advent-of-code/blob/master/2023/day8/index.js
Link to full solution
Solution
part 1
Here you have the code: https://github.com/crixodia/aoc/tree/main/2023/08_haunted_wasteland
Github
It's somewhat slow, but works Solution
You know what? Getting my rear kicked every year since 2018 pays off. I may have given up on day 15 of AoC 2019, but I did learn something. That's why about 10 minutes into my naive approach's fantastillion iteration, I recalled the Jupiter moons puzzle. As soon as I saw that this approach would work for the test data, it felt good. So to solve part 2, I just needed to look up a nice lcm-of-a-list formula.
Had some fun with the fact that the input is valid Python syntax, which in turn only made part 2 more tedious and the whole thing harder to debug.
Also on GitHub.
[LANGUAGE: PHP] https://github.com/mikedodd/AdventOfCode2023/tree/main/day_8
https://github.com/rumkugel13/AdventOfCode2023/blob/main/day08.go
Day8 in Rust
GitHub
code
English
[Language: Go] Didn't solve the part2 on my own, listened to the explanation here GitHub
[Language: Rust] Link
Code
Github
Github link
Classic LCM
Repo
Parser
My complete solutions including run scripts on GitLab
Solution
Part 1: Pretty simple, sure I could reduce it a bit, but was quick with the answer.
Parts 1 & 2
[Language: MiniScript] Link to code on GitHub
Part 2
Code: Github
Code
both parts: https://github.com/Josef-Hlink/AoC/blob/main/paoc/y23/solutions/day08.py
https://github.com/thygrrr/AdventOfCode2023/blob/main/day8.py
Part 1 straightforward implementation. Treat it as a graph and just follow the instructions.
Aww, Eric was too kind to us and made sure that we didn't have to detect loops! With some nifty optimisations, my whole program runs in 2.5 ms on a Raspberry Pi 4. Code with lots of comments: https://github.com/ednl/adventofcode/blob/main/2023/08.c My walk function:
Code: https://github.com/Withered-Flower-0422/AoC-2023-MiniScript/tree/main/day8
Quickly realized there must be a loop somewhere and scratching my head to detect it. Then browsing this sub revealed that loops don't start in the middle. That directly pushed part 2 to LCM. Code
YouTube cast: https://youtu.be/cgPpC-gzvQA GitHub [Rust]: https://github.com/samoylenkodmitry/AdventOfCode_2023/blob/main/src/day8.rs
code
Github
link
fyi there is std::fs::read_to_string std function (or even better include_str! macro) check out my nice 69 lines
I was able to solve part 1 without a problem then realized after trying to brute force part 2 that there must be a trick that I was missing (because my script never stopped running). Had to use a hint on reddit for the LCM solution unfortunately. I really don't know how anybody can just intuitively think to use LCM off the top of their head for a problem like this... pattern recognition I guess? Anywho, you live and you learn. Part 1
GitHub
Day_8: adventOfCode2023/Day_8 at master · monpie3/adventOfCode2023 (github.com)
Part 2: this one was far more difficult, and saw on reddit that one of the debug numbers my script was outputting was actually the answer...
Here's today's one-liners! Part 1 on line 40 and Part 2 on line 66.
Solution on github
Github
I wouldn't have figured out the LCM part myself although in hindsight it's obvious.https://github.com/Kenneth-Sweet/adventOfCode/blob/main/day8part1.cpp
TIL about LCM :) Solution for day 8: GitHub
Both parts on GitHub
Part 1
Code on [Github](https://github.com/estherlurie/aoc-2023/blob/main/src/day8.rs)
[LANGUAGE: Rust]I was running in circles trying to solve this one.First part was easy enough. I was running into an infinite loop in part 2 and then sadly was spoilered the LCM solution. At least I head fun optimizing the code :)Part 2: I converted the 3 char node names into u16 keys. I store the keys of the left/right successors of each node in a massive array, which I can simply index with they node keys. This proved significantly faster than a HashMap. While converting lines into nodes, I store all keys of nodes ending in an A in a starting nodes array. Next, I calcualte the cycle length for each starting row and then calculating the common LCM. I used rayon to speed things up with multithreading (minor improvement)[Code]
Solution with LCM method
Part 2 Runs basically instantly
Like others, I used lcm. Here's an extract of the solution, omitting parsing and main(). Full solution on GitHub.
code
My other solutions this year are here if you'd like to see, I may add last year's at some point: https://github.com/users/bofstein/projects/1
Day 08 Solution
Yet another python solution
[Language: Python] https://github.com/gonzafernan/adventofcode/blob/main/2023/8/day8.py
This was a tricky one, but I managed to solve it in an effective way (the lcm method). As always you can see it on my GitHub.
https://github.com/carl-omniart/advent_of_code/tree/main/2023 For part two, I defined a class that, in my head, was a cross of a Set and an Enumerator. This class took the offset (span of steps prior to a repetition), the period (span of repeated steps), and the points (steps that reached a location ending in Z). Knowing the pattern, an instance of this class quickly enumerates all the Z-ending steps between any span of steps. Instances of this class can be combined. The new offset is the greater of the two offsets; the new period is the lowest common multiple of the two periods. To get the new set of points, I used one instance to enumerate the points over the span of the new first period and checked to see if the other instance included them. The instance doing the enumerating was always the one in which the points were more spread out. (If you were trying to find a common multiple between 3 and 5167, you'd rather enumerate 5167 three times than three 5167 times.) I combined the various ghost paths and found the first point. P.S. I named this class Syzygy, which is a term for an astronomical conjunction and a title of an X-Files episode that features a young Jack Black. Doesn't exactly make sense as a class name here but what the heck.
Step-by-step explanation | full code
Got the answer for Part 2 by doing prime factorization, but later rewrote with lcm
Part 1 is pretty trash, but part 2 works great using lcm
My solution: https://github.com/timotree3/aoc2023/blob/main/roc/day8.roc
Solution: Day 8
github