NobbZ
Note by the Moderators: This topic is to talk about Day 3 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.
And day 3 is solved as well.
On my VM in the office both parts take about 1 to 1.25 seconds. Thats OK for me today. But the first iteration I used to get the actual solutions has some repitions in it, which I do not like.
I really have to iterate on those, and perhaps I’ll be even able to get them more efficient?
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
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
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
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
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sorentwo
Finding a timely solution for Day 03 took me a little bit. Originally I wanted to use a range to detect overlap, but that wasn’t available so I moved on to constructing sets and counting from there. That wasn’t ideal either, and in the end using a simple map to count tuples was quick enough.
simon
Day 3 was the most time consuming so far but also the most satisfying because I’m getting a bit more confident with
Enumand I’m also picking up ideas from @josevalim’s daily Twitch streams.My day 3 code is at https://github.com/simon-wolf/advent-of-code-2018/blob/master/lib/advent_of_code_2018/day_03.ex
My main concern with all of my code so far is that I need to break it into smaller chunks and/or add more comments because I’m not entirely sure that I’ll understand it all by the end of the challenges. Or maybe I will because I’ll be much more familiar with Elixir than I am right now.
yawaramin
I approached Day 3 as a set intersection problem, the only issue was finding a data structure to represent the claims that would be usable as set elements (i.e. comparable for uniqueness). I realized I could cleanly map each claim to a set of coordinates of the exact square inches of that claim; after that the solution fell into place as a series of set intersections and unions.
Here it is: advent_of_code_2018/lib/day3.ex at d65581aeb7b25f40d22a05c1435b1401b2505fef · yawaramin/advent_of_code_2018 · GitHub
Btw, I thought I’d share this fun fact that Elixir is in the top ten (at 10th) languages being used for Advent of Code projects on GitHub: Repository search results · GitHub
debajit
My solution for Day 3 Part 1:
I’m reasonably happy with how it turned out.
(I spent quite a bit of time trying to learn how to use the Tensor library (Tensor.Matrix provides matrix operations). I also looked at Matrex, but failed to install it.
In the end I used a simple sparse matrix representation using a map with
{row, col} => 1items to represent the matrix. Using the regex named captures was fun — it was something I learned the hard way from a personal project previously.)(Haven’t been able to look at Part 2 yet — its late night already, will look at it tomorrow)