From a63c3aeb4e773b078f8d4348661f0802a91534dc Mon Sep 17 00:00:00 2001 From: Adam Millerchip Date: Mon, 7 Dec 2020 18:42:38 +0900 Subject: [PATCH] s/children/descendants/g --- day7/day7part2.exs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/day7/day7part2.exs b/day7/day7part2.exs index f2e16db..341f6b7 100644 --- a/day7/day7part2.exs +++ b/day7/day7part2.exs @@ -4,13 +4,13 @@ defmodule Day7Part2 do def run do File.read!("input") |> input_to_tree() - |> count_children("shiny gold") + |> count_descendants("shiny gold") |> IO.puts() end - def count_children(tree, name) do + def count_descendants(tree, name) do Enum.reduce(tree[name], 0, fn {size, child_name}, count -> - count + size + size * count_children(tree, child_name) + count + size + size * count_descendants(tree, child_name) end) end