Aetherus
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
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
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
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
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
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: