clearer variable names
This commit is contained in:
parent
6c003ed3c2
commit
9345419941
1 changed files with 10 additions and 10 deletions
|
@ -1,14 +1,14 @@
|
|||
#!/usr/bin/env elixir
|
||||
defmodule Day8 do
|
||||
def part1({x, y, antennas}) do
|
||||
Enum.reduce(antennas, MapSet.new(), fn coords, antinodes ->
|
||||
MapSet.union(antinodes, find_antinodes(coords, x, y))
|
||||
def part1({x, y, frequencies}) do
|
||||
Enum.reduce(frequencies, MapSet.new(), fn antennas, antinodes ->
|
||||
MapSet.union(antinodes, find_antinodes(antennas, x, y))
|
||||
end)
|
||||
|> MapSet.size()
|
||||
end
|
||||
|
||||
def find_antinodes(coords, x, y) do
|
||||
coords
|
||||
def find_antinodes(antennas, x, y) do
|
||||
antennas
|
||||
|> find_pairs()
|
||||
|> Enum.flat_map(fn pair -> calc_antinodes(pair, x, y) end)
|
||||
|> MapSet.new()
|
||||
|
@ -28,15 +28,15 @@ defmodule Day8 do
|
|||
end)
|
||||
end
|
||||
|
||||
def part2({x, y, antennas}) do
|
||||
Enum.reduce(antennas, MapSet.new(), fn coords, antinodes ->
|
||||
MapSet.union(antinodes, find_resonant_harmonics(coords, x, y))
|
||||
def part2({x, y, frequencies}) do
|
||||
Enum.reduce(frequencies, MapSet.new(), fn antennas, antinodes ->
|
||||
MapSet.union(antinodes, find_resonant_harmonics(antennas, x, y))
|
||||
end)
|
||||
|> MapSet.size()
|
||||
end
|
||||
|
||||
def find_resonant_harmonics(coords, x, y) do
|
||||
coords
|
||||
def find_resonant_harmonics(antennas, x, y) do
|
||||
antennas
|
||||
|> find_pairs
|
||||
|> Enum.flat_map(fn pair -> calc_resonant_harmonics(pair, x, y) end)
|
||||
|> MapSet.new()
|
||||
|
|
Loading…
Reference in a new issue