JEG2

JEG2

Author of Designing Elixir Systems with OTP

Note: This topic is to talk about Day 9 of the Advent of Code.

For general discussion about the Advent of Code 2018 and links to topics of the other days, see this topic.

Showing Posts 1 to 6

JEG2

JEG2 OP

Author of Designing Elixir Systems with OTP

Here’s my solution to Day 9:

https://github.com/JEG2/advent_of_code_2018/blob/master/day_09/marble_mania.exs

Inspired by @josevalim, I live streamed the creation of it for the first time. You can watch the video here (until it falls off Twitch 14 days from now):

The main idea is just that I hand-rolled a doubly linked list and used that to solve both problems. It does part two in a little under a minute. I’m looking forward to seeing how others do it faster.

sasajuric

sasajuric

Author of Elixir In Action

This is my solution to day 9. On my machine it takes some 3.5 sec for the second part. The key idea in my solution is to use zippers to implement a circular list.

davydog187

davydog187

Here’s my naive solution use a single list. The implementation was too slow to solve the second part. advent_of_code_2018/advent_elixir/lib/advent_elixir/day_9.ex at master · davydog187/advent_of_code_2018 · GitHub

sfusato

sfusato

I liked your implementation of a linked-list as a Map structure. Also, the way you’ve found the 7th marble counter clockwise from the current one using Stream.iterate was awesome. I need to get acquainted with the Stream module more that’s for sure. I’ve enjoyed your stream. Thank you!

My very naive implementation wouldn’t complete Part 2 within the time I was willing to wait for it to do so. I got Part 1 and the given tests passing, so I’m cool with that.

poligen

poligen

Thank you so much to reply here !!@sasajuric. It is the most important key to solve this problem using your zipper list. I learn a lot from this zippers.
:heart_eyes:

simon

simon

My solution is here and it calculates the part 2 solution in about 30 seconds.

I need to now look at what others have done but I think I was on roughly the right track by creating a map where the key is the turn number and the value is a struct containing the previous and next keys so that you can step forwards and backwards from the current marble.

My code to update the struct isn’t terribly concise and that may be a good place for performance improvements but @sasajuric’s solution seems to be the one I need to look at in depth as well as the aforementioned zippers.

— All posts loaded —

Where Next? Top

Trending in Challenges Top

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
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
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews