From ab7c6d5d333227f055476e1f7a15a2aca9b37c27 Mon Sep 17 00:00:00 2001 From: Adam Millerchip Date: Thu, 17 Dec 2020 12:07:00 +0900 Subject: [PATCH] reduce -> map_reduce --- day16/day16part2.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/day16/day16part2.exs b/day16/day16part2.exs index 8c697b5..9a73c7d 100644 --- a/day16/day16part2.exs +++ b/day16/day16part2.exs @@ -44,9 +44,9 @@ defmodule Day16Part2 do def reduce_to_column_by_field_name(valid_fields_by_column) do valid_fields_by_column |> Enum.sort_by(fn {_k, v} -> length(v) end) - |> Enum.reduce({[], []}, fn {col, fields}, {identified, seen} -> + |> Enum.map_reduce([], fn {col, fields}, seen -> [field] = fields -- seen - {[{field, col} | identified], [field | seen]} + {{field, col}, [field | seen]} end) |> elem(0) end