Simplify with Enum.into/2

This commit is contained in:
Adam Millerchip 2024-12-09 12:23:29 +09:00
parent fcbf4aa683
commit 04970d3ed6

View file

@ -5,8 +5,7 @@ defmodule Day8 do
antennas
|> find_pairs()
|> Enum.flat_map(fn pair -> find_antinodes(pair, x, y) end)
|> MapSet.new()
|> MapSet.union(antinodes)
|> Enum.into(antinodes)
end)
|> MapSet.size()
end
@ -30,8 +29,7 @@ defmodule Day8 do
antennas
|> find_pairs()
|> Enum.flat_map(fn pair -> find_resonant_harmonics(pair, x, y) end)
|> MapSet.new()
|> MapSet.union(antinodes)
|> Enum.into(antinodes)
end)
|> MapSet.size()
end