Papey
This topic is about Day 23 of the Advent of Code 2020 .
Thanks to @egze, we have a private leaderboard:
https://adventofcode.com/2020/leaderboard/private/view/39276
The join code is:
39276-eeb74f9a
Trending in Challenges
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Papey
For this one I’ll go for a good old pen and paper to run the algorithm in order to find how the pieces fits together
A geat day to work with
Stream!hvnsweeting
Part 1 is simple with list but that would take forever to run part 2. I also tried paper and pencil to calculate as it seems to have some pattern, failed to this. Then I tried to speed up code of part 1,end up implementing a fast linked list.
https://github.com/hvnsweeting/adventofcode/blob/master/lib/2020/aoc2020_day23.ex
Papey
Bruteforce is the key !
https://github.com/papey/aoc/commit/e7c59f7c85ba22e9030a5882edcc1dba983ea55c
bjorng
I spent most of the day trying to find patterns in the input and also trying to optimize my solution. I found several ways to speed up the moves up to 250000 moves, but whatever I did after that, the solver slowed down to a crawl. I then scrapped my code and implemented a double linked list using a map.
Here is my solution.
UPDATE: I realized that there is no need to use a doubly-linked list. I have updated my code.
Hallski
Really enjoyed today, learnt a lot from trying to figure out how to represent a linked list with immutable data structures without having to recreate large parts of the list when moving data.
Thanks @hvnsweeting for the perfect cut off in your post above that got me unstuck!
Ended up rewriting part 1 on the new code as it turned out more readable than my initial implementation, as well as being faster.
My code for today
code-shoily
Fell asleep last night. Here’s how I did the first part:
I think I missed a chance to apply some Stream-fu.
adamu
Still playing catch-up so just got around to this one. This was great, especially Part 2.
I’d be very interested to know people’s running times for Part 2.
I also did Part 1 using lists and Stream, which was elegant enough but completely unworkable for Part 2.
For Part 2, I felt we were sort of working around the immutable environment. I used
:etsto implement a doubly-linked list to represent the circle (storing the previous and next elements). My implementation takes 22 seconds on my machine, so I’m interested if anyone got good performance without resorting to native code.I used
.
:etsbecause wanted to use something with constant insert time compared to map, which has log(n) insert time. I also considered:array, but the docs didn’t say anything about performance, whereas:etspromised constant time insert/retrieve operations, so I went with that. This was my first time using ETSDay 23 Notes.
Sounds nice, but I ran your answer and it takes 40s on my machine, compared to 22s for my answer using
:etsinstead of maps. I think you’re right though, there’s no need to be able to traverse the list backwards so I over-engineered that too.bossek
Solution using atomics: AoC 2020 Day 23 Part 2 (atomics) · GitHub
bjorng
Getting rid of the back links reduced the running time from 80 seconds to 40 seconds on my computer as well as simplifying the code. I didn’t bother doing any more optimizations.
I have not tried it myself, but I would expect that using the
atomicsmodule would give a nice speedup.bjorng
That is 2.7 seconds on my computer. Nice!
