Advent of Code 2015 Day 3 Part 1
Mix.install([
{:kino_aoc, "~> 0.1"}
])
Get Inputs
{:ok, puzzle_input} =
KinoAOC.download_puzzle("2015", "3", System.fetch_env!("LB_SESSION"))
My answer
puzzle_input
|> String.codepoints()
|> Enum.reduce({{0, 0}, [{0, 0}]}, fn direction, {{x, y}, houses} ->
new_point =
case direction do
">" -> {x + 1, y}
"<" -> {x - 1, y}
"^" -> {x, y + 1}
_ -> {x, y - 1}
end
{new_point, [new_point | houses]}
end)
|> elem(1)
|> Enum.uniq()
|> length()