bjorng
Erlang Core Team
This topic is about Day 22 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
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
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
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
bjorng
Nice with a simpler puzzle after days 19 and 20. In my solution I first tried to use the Erlang’s :queue module, but it turned out that in part 2 a simple list was faster because of the need to keep track of previous states. The running time is 1.5 seconds for both parts on my computer, while the running time for using
:queuewas almost 3 seconds.code-shoily
This one was easy, took me awhile to understand the recursion rule for the recursive combat but once I got it, it was pretty straight-forward. I did think about using
:queuebut felt like trying without first.faried
The recursion rules tripped me up several times. My part 2 returned the right answer when I ran it with both the infinite example and the worked-out example, and it was only when I traced through the latter that I realized I had to copy a slice of the deck of cards, not the entire rest of the deck.
It does too much work.
mexicat
Not very optimized (~1.3s on my laptop) but at least it was quick and easy to write!
lud
Mine ran for 20 minutes and never completed. I totally missed the rule that for recursive combat you have to take only a subset of the remaining cards (long as the drawn card), and not the entire remaining deck cards.
hvnsweeting
Simple one but has multiple places can be missed:
https://github.com/hvnsweeting/adventofcode/blob/master/lib/2020/aoc2020_day22.ex
Hallski
After reading the text I couldn’t resist, it felt like a too good fit for Erlang/Elixir to pass up.
My code
Papey
Nice and clean really liked this one !
camilleryr
I used
:queue, but after reading @bjorng experience I may try and refactor to using lists to see if I get a performance boost - my part two is at ~750ms right now, so if I could get it to run twice as fast, that would be fun. I also ran into the issue where missing the rule about the subset of the deck for the recursive game caused an infinite loop, and then when I added that rule it, it was still just slow enough to make me sweat for a secondI would like to spend a little time making it a little easier to track whats happening since the recursive rules are a bit of a mess of nested conditionals right now…
https://github.com/camilleryr/advent20/blob/main/lib/day_22.ex
code-shoily
Fastest I could get on my machine was ~150ms, I tried using ETS but that didn’t improve much, anyone got good optimization on this (part 2)?