Aetherus
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
- #security
- #hex











First 10 of 33 Posts!
Aetherus
My solution:
For part 2, just modify this line:
|> Enum.count(ok_for_part1?)adamu
Bit cheeky to mark your own post as the solution
My answer was pretty similar, but I used a Regex with captures to parse the input - I prefer your use of
String.splitthough. I was wondering if it was worth importingBitwise, but like you I just wrote it manually.Aetherus
I’d like to mark everyone’s working code as solution, mine included
The
Bitwise.^^^/2only works on integers, so we can’t use it.bossek
Following should work:
Aetherus
Since the input is all ANSI characters, it could be faster just handling bytes.
String.at(string, n)is O(n) ifstringcontains only ANSI characters, but:binary.at(binary, n)is O(1). (Confirmed using Benchee)everte
I’m the only one who didn’t think about using regex it seems, although I think I like the String.split method used by Aetherus.
Thanks for sharing the solutions, it definitely gives me some inspiration on how to improve mine:
https://git.sr.ht/~servert/aoc2020/tree/master/day2/lib/day2.ex (not sure how to link to the version in this specific commit on sourcehut so it’s immutable).
Aetherus
Thank you for sharing your solution. I like the pins
faried
Enum.count! That could’ve helped me. Oh, well.mexicat
My solution.
Edit: I forgot about
String.at, that’s probably a minor refactor that could be done.hauleth
My approach to make it not only fast, but also clean and readable:
Last Post!
APB9785
This seemed to be all about parsing the input properly. I chose to use a list of 4-tuples, and from there, both parts were trivial to solve.
Full solution @ Github