Skip to content

Commit 89e012f

Browse files
committed
Make it faster
1 parent 266e9d6 commit 89e012f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/2018/day_06.ex

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ defmodule AdventOfCode.Y2018.Day06 do
1919
def run(input \\ input()) do
2020
input = parse(input)
2121

22-
{covers_most_points(input), covers_distances_within(input, 10_000)}
22+
task_1 = Task.async(fn -> covers_most_points(input) end)
23+
task_2 = Task.async(fn -> covers_distances_within(input, 10_000) end)
24+
{Task.await(task_1), Task.await(task_2)}
2325
end
2426

2527
@spec parse(binary()) :: points()
@@ -92,6 +94,6 @@ defmodule AdventOfCode.Y2018.Day06 do
9294
end
9395

9496
defp within_distance_threshold(distances, threshold) do
95-
Enum.sum_by(distances, &elem(&1, 1)) < threshold && 1 || 0
97+
(Enum.sum_by(distances, &elem(&1, 1)) < threshold && 1) || 0
9698
end
9799
end

0 commit comments

Comments
 (0)