bismark
Took me a minute to remember my binary math
..
import Bitwise
__DIR__
|> Path.join("puzzle.txt")
|> File.stream!()
|> Stream.filter(fn line ->
line
|> String.trim()
|> String.split(",")
|> Enum.map(fn range ->
[s,e] = range |> String.split("-") |> Enum.map(& String.to_integer(&1))
Integer.pow(2, e - s + 1) - 1 <<< (s - 1)
end)
|> Enum.reduce(fn int1, int2 ->
intersection = int1 ||| int2
intersection == int1 or intersection == int2
end)
end)
|> Enum.count()
|> IO.puts()
import Bitwise
__DIR__
|> Path.join("puzzle.txt")
|> File.stream!()
|> Stream.filter(fn line ->
line
|> String.trim()
|> String.split(",")
|> Enum.map(fn range ->
[s,e] = range |> String.split("-") |> Enum.map(& String.to_integer(&1))
Integer.pow(2, e - s + 1) - 1 <<< (s - 1)
end)
|> Enum.reduce(fn int1, int2 ->
(int1 &&& int2) != 0
end)
end)
|> Enum.count()
|> IO.puts()
Edit: oops, I’m supposed to import not use Bitwise now..
Trending in Challenges
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
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
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
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
- #ai
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
code-shoily
I am grateful for
MapSetmodule. Not every language is blessed with a set API that has common set operations.https://github.com/code-shoily/advent_of_code/blob/master/lib/2022/day_04.ex
srowley
Second half was actually a little simpler.
stevensonmt
Basically did the same. I wasn’t as clever with your use of the
&&and||operators to convert to numbers. I just filtered and counted.deadbeef
Like others, using
Rangehttps://github.com/ed-flanagan/advent-of-code-solutions-elixir/blob/main/lib/advent/y2022/d04.ex
adamu
Ooh, TIL, I started with
Ranges, but then converted them toMapSets - I didn’t consider that we can do it, especially part 2, directly with the range. This is why AoC is greathttps://git.adamu.jp/adam/AdventOfCode/src/branch/main/2022/day4.exs
lkuty
part 1
part 2 is very similar to part 1.
mudasobwa
and then
kwando
clever parsing
markholmes
I’ve been working through AOC using Gleam this year! This is probably pretty terrible Gleam code, but it’s Elixir-adjacent so I thought I’d share
https://github.com/markholmes/aoc/blob/main/src/y_22/d_04.gleam
christhekeele
I also went with parsing into
Ranges, and was also surprised to learn aboutRange.disjoint?/2solving part two that literally did all the work compared to part one.What I really found impressive is that
disjoint?handles steps with ranges, as well! That’s a cool technique.