lud
Hello everyone!
This year is going to be shorter, but the difficulty will grow faster. Today I already feel that this is not standard “Day 1” difficulty.
Or I am really overcomplicating things. Didn’t sleep well ![]()
defmodule AdventOfCode.Solutions.Y25.Day01 do
alias AoC.Input
def parse(input, :part_one) do
input
|> Input.stream!(trim: true)
|> Enum.map(fn
"R" <> n -> {:right, String.to_integer(n)}
"L" <> n -> {:left, String.to_integer(n)}
end)
end
def parse(input, :part_two) do
input
|> Input.stream!(trim: true)
|> Enum.flat_map(fn
"R" <> n -> expand_rotation(:right, String.to_integer(n))
"L" <> n -> expand_rotation(:left, String.to_integer(n))
end)
end
defp expand_rotation(direction, amount) when amount <= 100 do
[{direction, amount}]
end
defp expand_rotation(direction, amount) when amount > 100 do
[{direction, 100} | expand_rotation(direction, amount - 100)]
end
def part_one(problem) do
problem
|> Stream.scan(50, fn
{:left, n}, acc -> Integer.mod(acc - n, 100)
{:right, n}, acc -> Integer.mod(acc + n, 100)
end)
|> Enum.count(&(&1 == 0))
end
def part_two(problem) do
problem
|> Stream.transform(50, fn
{:left, n}, acc ->
new_acc = Integer.mod(acc - n, 100)
{[{:left, acc, new_acc}], new_acc}
{:right, n}, acc ->
new_acc = Integer.mod(acc + n, 100)
{[{:right, acc, new_acc}], new_acc}
end)
|> Enum.count(fn
{_, _, 0} -> true
{_, 0, _} -> false
{:right, a, b} when a > b -> true
{:left, a, b} when a < b -> true
{_, same, same} -> true
_ -> false
end)
end
end
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
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
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
- #elixirconf-us
- #ai
- #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)
code-shoily
This year I am using Clojure. But I did something similar. Had to look for all the cases:
divvalue and1000and current diff is negative? The nothing changes, otherwise,incrthe zero values100? Then we definitely crossed zero one more time -incrthe zero valuesThat was how I did the second part. One interesting thing, if you miss
2or4- the example inputs give you6- but the final input doesn’t match, I wonder if that was intentional.Another thing, that reminds me of the
seveninesituation in2023- the> 100cases was hidden from example input. Sneaky lol.I have a feeling I can get a formula for this. Will be following y’all to see how you did it.
bjorng
Yes, definitely a little bit harder, especially part 2.
sevenseacat
oh, so many off-by-one errors in part 2. I’m a wee bit out of practice!
https://github.com/sevenseacat/advent_of_code/blob/main/lib/y2025/day01.ex
My insight was that wrapping from 0 → 99 → 00 doesn’t actually matter - all that matters is whether or not the current position is divisible by 100.
hauleth
Part 2 was PITA, but managed:
rvnash
Not too hard, had to wrap my head around how many zero crossing occur when turning left.
tnlogy
Hi! Nice to see some solutions to compare with since this is my first time using Elixir. I like it so far :).
This is my solution for day1, I tried to simplify part 2 by replacing the instructions with just +1 and -1. Maybe some of my code is a bit strange since I’m new to Elixir.
ken-kost
Not super satisfied with my solution.
nico_amsterdam
Lots of mod and div’s.
Insight in part 2: when the dail was pointing at 0, it is not an extra click when it goes to a negative number.
Solution in Livebook:
KeithFrost
Part 1
Part 2
billylanchantin
Boilerplate
Part 1
Enum.scan/3works really well here.Part 2
It’s tempting to do math, but reusing prior work is simpler if less performant.