bjorng
Erlang Core Team
Note: This topic is to talk about Day 9 of the Advent of Code 2019.
There is a private leaderboard for elixirforum members. You can join it by following this link and entering the following code:
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
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
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
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
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
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #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
Here is my solution.
sb8244
Nothing too exciting in my code here. My intcode computer has overall been a bit of a mess due to not going back and cleaning it up.
This problem really showed some issues in how I had implicit rules baked into my code. I was not putting arg 3 through any type of mode checking, because it was always itself previously. That bit me hard today, and I had to spend a ton of time debugging why my stuff wasn’t working.
mason-bially
I got top 80-90! Here is the meat of my solution.
I specifically designed my intcode interpreter to allow rapid extension of it, I even spent an hour cleaning it up the other day, seems like that paid off.
It’s pretty cool to see how well a recursive interpreter of a self-modifying memory/code VM actually ends up working with immutable memory. Very fun.
I would also be curious about the timings people got on the second part. Mine was 3.860 seconds (timed from the shell).
sb8244
Wow!!! Great work. That’s super speedy.
I’m honestly surprised here. I feel like I didn’t do anything special to make mine fast, but it is significantly faster than 3s.
Do you use lists in your solution?
edit: I see that you use
:array. I believe that switching over to an index based map would speed yours up significantly. I’ve learned to very rarely use[]or:array, from last year’s AoC.mason-bially
To be clear I have used elixir less than a week and know nearly nothing about optimizing it (or erlang), I use advents of code to learn new languages.
I was worried a list would be too slow because of the O(n) access and couldn’t find good information on optimization. I figured the erlang
:arraywould probably be better than that.Could you point me to the documentation for what you are describing?
Edit: Is it simply just using integers in a map?
bjorng
Both parts finish in 0.1 seconds:
mason-bially
Looking at your code I feel like an idiot for missing that I can use the function pattern matching as a sort of multi-method. I may need to do some additional refactoring.
I’ll still have to always write a forwarding method, but it might make it a cleaner copy paste in the end rather than doing what I am now with the explicit forwarding.
sb8244
Hm, I’m wrong here. I tried to do a benchmark with
:array.getand:array.setvs Map functions and they were about the same. I’m not sure why it would be so much slower without digging in more.mason-bially
I suspect my use of
.exsand dynamically loading my libraries withCode.require_file("../day07/el.ex", __DIR__)might have something to do with it.I haven’t learned mix yet…
Anyway thanks for the feed back! It was very useful.
Edit: some other possible reasons:
I’ll have to play around with it.
sasajuric
This is my solution. So far I strived to keep the code clean, and this payed off, b/c the changes to the machine code were minimal. I finally extracted Intcode interpreter into a separate module, but I still keep that module code in the same file as the solution, so others can easily read the entire solution from a single file. As for the perf, the 2nd part takes about 500ms on my machine.