Aetherus
This topic is about Day 3 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
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 25 to 16- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
APB9785
Part 1: Basic modulo wrap
Part 2: In the Functional style:
where ‘travel’ traverses the map with slope -1 / n, and ‘travel2’ uses slope -2.
Full solution @ Github
NobbZ
https://gitlab.com/NobbZ/aoc_ex/-/blob/master/lib/y2020/d03.ex
Better late than never!
deadbeef
There’s plenty of overlap in my solution, but didn’t see the exact one, so figured I’d share. (Brand new to Elixir, Advent of code has been a great way to practice.)
down’th rowrem(right * idx, with)is#Idea was to stream the file and only aggregate at the count step, as to not use intermediate lists
Rainer
And here my Erlang solution, part 2 with skipping down gave me some troubles first too
Even it was fun, I’m not shure whether I’ll progress, as my time is quite limited atm.
stevensonmt
Wow, some really interesting solutions here. Mine is a fairly basic recursive approach that relies on processing the input into a list of strings. It is brittle because if the strings are of unequal length it would fail. I also hardcoded the string length in the
rem/2call, which I could have avoided by introducing another module attribute like@line_lengthor something.Aetherus
Yay! I learned it in Day 1
I used it to create a stream that lazily yields k-element combinations of a given list, just like Ruby’s
Array#combinationwithout a block.ricardo-h
O(mn) solution
faried
I clearly need to spend more time with the
Streammodule. I picked an easy way to do it:dominicletz
I think my solution is similar to that of @LostKobrakai @egze, using
rem(position, length(line))to map the large position into the small map.The two novelties I can offer are:
Git Repo
al2o3cr
Stream.transformhas a bit of a learning curve, but you can make it do basically anything that involves “look at each element of this list, plus some information from previous iterations, and return some results and information for the next iteration”.https://github.com/al2o3cr/advent-of-code-2020/blob/main/day3/part1.exs
This solution transforms the file (one line at a time) into a stream of
{"..#", row#, col#}tuples representing the path, then counts the ones that have a tree at the correct column.The day2 version uses a neat property of
transform- returning[]works like it does inflat_mapand produces no output, so skipping rows (for the “down 2 over 1”) case is easy.