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
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
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
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










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