Last active
December 4, 2022 16:19
-
-
Save ThiagoPMaceda/1fceec904b2d70d3f6162b72c1be93c5 to your computer and use it in GitHub Desktop.
AoC 2022, day 1 - Challenge 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File.read!("day_1_input.txt") | |
|> String.split("\n", [trim: false]) | |
|> Enum.reduce({[], []}, fn input, {full_list, current_list} -> | |
case input do | |
"" -> {full_list ++ [current_list], []} | |
_ -> integer_parsed_input = String.to_integer(input) | |
{full_list, current_list ++ [integer_parsed_input]} | |
end | |
end) | |
|> elem(0) | |
|> Enum.reduce([], fn list, acc -> acc ++ [Enum.reduce(list, 0, &(&1 + &2))] end) | |
|> Enum.max() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment