LostKobrakai
Advent of Code 2020 - Day 9
This topic is about Day 9 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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
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
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #elixirconf-us
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #performance
- #security










First 10 of 12 Posts!
LostKobrakai
Todays challenge was mostly a matter of chunking data in a fitting matter for the questions asked:
https://github.com/LostKobrakai/aoc2020/commit/2734ef2469be42ebcffe9f09d5ce539a2521d608
Edit:
Used a little more time to actually use the proper type for the fifo accumulator needed in part 2:
:queue.https://github.com/LostKobrakai/aoc2020/commit/18dc68ea581b65183db492672bcdf12e5c49d57f
faried
The test input worked for my part 2, but the real input failed. I missed the bit about adding the smallest and largest values in my readthrough.
dams
I used gb_trees for part 1, shorten the code.
Part1
Part2:
hvnsweeting
Hello,
my first time post here, but I joined the board and solve AOC in Elixir since 2019. Last year I tried to do everything using tail-recursive but this year try to utilize more built-in function from Enum, such as
find_valueor comprehensions.adamu
Ahh,
:queueis pretty cool. I looked into:array, but didn’t think of queue, although that seems perfectly fitted for a sliding window.In the end I used lists, but implemented the sliding window with recursion to avoid inefficiently reading from / appending to the end of arbitrary-length lists.
Parts 1 and 2 complete in about a millisecond each, so I think it’s ok.
https://github.com/adamu/AdventOfCode2020/blob/main/day9/day9part2.exs
code-shoily
I know how that feels. I once had a situation where test input worked, my real input did not work, but inputs from my friends worked. Seems like there was a special case my input had which I did not take into account. Also, in yesterday’s solution, I had replaced “nop” and “jmp” both with “nop” and it still worked (I realized the typo later).
Anyways, staying true to the thread topic, here’s my solution for the day, nothing special, good old brute forcing
stevensonmt
I also took a brute force approach. I’m sure there is ample room for optimization, but after struggling so much with the last two days, I was just happy to be able to get this right away.
stevensonmt
umm, what? Is generating combinations really that simple? That’s brilliant.
kwando
This is the first version that worked, I later realized part 1 is a bit stupid and inefficient.. but I’m not in the mood to patch it up right now
ricardo-h
part 1 and 2 - O(n m)
Last Post!
adolfont
i tried something different with #AdventofCode2020 Day 9. I did not solve it. I tried to understand and refactor a Day 9 solution from somebody else.
The code (from Martin Gausby and @LostKobrakai) is rewritten or commented here: https://github.com/Introduction-to-Functional-Programming/simple_exercises/blob/main/adolfont/adventofcode/2020/day_09/lib/day09.ex.
I learned a lot.