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.
defmodule Advent2025Test do
use ExUnit.Case
doctest Advent2025
def day1_data() do
"day1.txt"
|> File.stream!()
|> Stream.map(fn line -> String.split_at(line, 1) end)
|> Stream.map(fn {dir, num} -> {dir, String.to_integer(String.trim(num))} end)
end
def day1_count(data) do
data
|> Enum.reduce({50, 0}, fn {dir, num}, {val, res} ->
Integer.mod(
val +
case dir do
"L" -> -num
"R" -> num
end,
100
)
|> then(fn new_val ->
{new_val, if(new_val == 0, do: res + 1, else: res)}
end)
end)
end
def day1_make_ticks(data) do
data
|> Stream.flat_map(fn {dir, num} ->
Stream.map(1..num, fn _ -> {dir, 1} end)
end)
end
test "day1_p1" do
{_, zeroes} = day1_data() |> day1_count()
IO.puts("answer #{zeroes}")
assert zeroes == 1048
end
test "day1_p2" do
# Same as part1, but make a list of just {"L", 1} and {"R", 1}
{_, zeroes} = day1_data() |> day1_make_ticks() |> day1_count()
IO.puts("answer: #{zeroes}")
assert zeroes == 6498
end
end






















