diff --git a/2021/README.md b/2021/README.md index e9e1649..e3448af 100644 --- a/2021/README.md +++ b/2021/README.md @@ -16,7 +16,7 @@ | :-: | :-: | :-: | :-: | :-: | :-: | :-: | | | | | [1] | [2] | [3] | [4] | | [5] | [6] | [7] | [8] | [9] | [10] | [11]| -| [12]| [13]| [14]| [15] | [16] | [17] | 18 | +| [12]| [13]| [14]| [15] | [16] | [17] | [18] | | 19 | 20 | 21 | 22 | 23 | 24 | 25 | @@ -38,3 +38,4 @@ [15]: ./lib/2021/15.ex [16]: ./lib/2021/16.ex [17]: ./lib/2021/17.ex +[18]: ./lib/2021/18.ex diff --git a/2021/lib/2021/18.ex b/2021/lib/2021/18.ex index 12303ff..c7ae6f4 100644 --- a/2021/lib/2021/18.ex +++ b/2021/lib/2021/18.ex @@ -10,6 +10,15 @@ aoc 2021, 18 do end def p2 do + numbers = input() |> Enum.to_list() + + for a <- numbers, b <- numbers, a != b do + concat(a, b) + |> reduce() + |> to_lists() + |> magnitude() + end + |> Enum.max() end def magnitude([a, b]) do