cblavier
Hey there ![]()

No magic or algorithmic finesse today, I just finished the challenge and I my code is quite slow (1sec for part1, 3sec for part2).
But at least I managed to made my code readable and to reuse most of part1 for part2.
Trending in Challenges
Other Trending Topics
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
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
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 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Aetherus
I did this too, and I want to see better solutions.
LostKobrakai
I’ve gone ahead with a genserver for the simulation (not really needed but
) and a state struct, which even implements
String.Chars(mostly for comparing to the examples in tests). I like the code, but it’s not very fast as well.https://github.com/LostKobrakai/aoc2020/commit/52a9f4866e22ccd6609dd6acc875fa9d1323f8a7
cblavier
by the way, I often need to do some
while true ... breakin AOC challengesHere is what I use instead:
Working, but I don’t really like the
[0]list coming from nowhere.Any other way?
LostKobrakai
Recursion if it’s truely
while doordo while:https://github.com/LostKobrakai/aoc2020/blob/master/lib/aoc2020/day11.ex#L182-L191
My other goto for evaluation (does not always fit) is
Stream.unfold:https://github.com/LostKobrakai/aoc2020/blob/d9e79ebd6cd6d346df1705fd7ef109bb4fa5f596/lib/aoc2020/day3.ex#L30-L39
aaronnamba
There are many cases where it works well to build a Stream, filter it, and take 1.
mexicat
Mine is also quite slow (~3s for p2) but at least the code is not too convoluted this time
faried
Could’ve used a better line of sight calculation. Oh, well.
faried
I can replace most of that crunk with
LostKobrakai
Most of those computations involving coordinates can be done with vector math and
{x, y}is basically the simplest form of representing an vector.Hallski
Ended up putting all the seats in a map and then lookup them up to calculate occupied seats. Also learnt the lesson of making sure to copy the entire test data instead of all but the last ten lines…
Anyone know of a nicer way to iterate a stream until it stabilises, what I ended up with felt a bit cumbersome.