adamu
Probably not the most efficient implementation, because part 1 took >1 ms and part 2 >4ms, but the code was simple enough.
def part1(input) do
input
# ...
|> Enum.map(fn {a, b} -> hd(a -- a -- b) end)
|> Enum.map(&score/1)
|> Enum.sum()
end
defp score(<<lower::utf8>>) when lower in ?a..?z, do: lower - ?a + 1
defp score(<<upper::utf8>>) when upper in ?A..?Z, do: upper - ?A + 27
https://git.adamu.jp/adam/AdventOfCode/src/branch/main/2022/day3.exs
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
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #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)
code-shoily
It was simple, today’s one. Not sure of the performance though. Basically it was a game of sets for me.
https://github.com/code-shoily/advent_of_code/blob/master/lib/2022/day_03.ex
mudasobwa
I went with charlists and
MapSets.hst337
Performance on my fingertips
stevensonmt
Did the same charlists and MapSets.
mcrumm
I started with a MapSet but ended up with a
:binary.match/2:https://github.com/mcrumm/aoc2022/blob/main/aoc2022-03.livemd
kwando
I outsourced the heavy lifting to
MapSet.intersectandcharlistsas wellI also realized you could just map all letters to their priority at the start so you only have to deal with integers later.
Function for converting
char→priorityAetherus
I just pipe to the bitter end
kwando
Nice touch to download the input from the interwebs
bmitc
Today’s was strangely easy, especially for languages like Elixir with piping and sets. Like others, I also used
charlistandMapSetto do everything. Although, I had to learn up on somecharlistbits.Livebook notebook: advent-of-code/2022/elixir/advent_of_code_2022.livemd at main · bmitc/advent-of-code · GitHub
LostKobrakai
This certainly was a quick one. Having used essentially
:binary.bin_to_list+Enum.findfor both parts.Solution