diff --git a/lib/day7.ex b/lib/day7.ex index 7ced72f..116acf1 100644 --- a/lib/day7.ex +++ b/lib/day7.ex @@ -6,8 +6,8 @@ defmodule Aoc2023.Day7 do |> Enum.frequencies() |> then(fn freq -> {jokers, freq_} = freq |> Map.pop(0, 0) - common = freq_ |> Enum.max_by(pipe(elem(1))) |> elem(0) - freq_ |> Map.update!(common, &(&1 + jokers)) + common = freq_ |> Enum.max_by(pipe(elem(1)), fn -> {1, nil} end) |> elem(0) + freq_ |> Map.update(common, jokers, &(&1 + jokers)) end) |> Enum.map(pipe(elem(1))) |> Enum.sort(:desc)