summaryrefslogtreecommitdiffstats
path: root/src/day06.exs
diff options
context:
space:
mode:
Diffstat (limited to 'src/day06.exs')
-rw-r--r--src/day06.exs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/day06.exs b/src/day06.exs
index 09a1604..8e339ff 100644
--- a/src/day06.exs
+++ b/src/day06.exs
@@ -32,15 +32,13 @@ defmodule Day06 do
{v, j} <- Enum.with_index(String.codepoints(line)) do
if v == element do
{i, j}
- else
- nil
end
end
|> Enum.filter(& &1 != nil)
end
- def part1({i, j}, grid) do
- path({i, j}, :up, grid)
+ def part1({guard, grid, _, _}) do
+ path(guard, :up, grid)
|> Enum.map(fn {i, j, _} -> {i, j} end)
|> Enum.uniq()
|> Enum.count()
@@ -89,7 +87,7 @@ defmodule Day06 do
end
end
- def part2(guard, grid, overt, ohori) do
+ def part2({guard, grid, overt, ohori}) do
path(guard, :up, grid)
|> Enum.map(fn {i, j, _} -> {i, j} end)
|> Enum.uniq()
@@ -160,12 +158,12 @@ defmodule Day06 do
end
end
-{guard, grid, overt, ohori} = IO.read(:stdio, :eof) |> Day06.parse_data()
+data = IO.read(:stdio, :eof) |> Day06.parse_data()
-{time1 , ans1} = :timer.tc(fn -> Day06.part1(guard, grid) end)
+{time1 , ans1} = :timer.tc(fn -> Day06.part1(data) end)
IO.puts("Time : #{time1 / 1000000}")
IO.puts("Answer: #{ans1}")
-{time2 , ans2} = :timer.tc(fn -> Day06.part2(guard, grid, overt, ohori) end)
+{time2 , ans2} = :timer.tc(fn -> Day06.part2(data) end)
IO.puts("Time : #{time2 / 1000000}")
IO.puts("Answer: #{ans2}")