|
|
@ -0,0 +1,16 @@ |
|
|
|
|
|
-module(foo). |
|
|
|
|
|
|
|
|
|
|
|
-export([main/1]). |
|
|
|
|
|
|
|
|
|
|
|
main(Args) -> |
|
|
|
|
|
[Filename] = Args, |
|
|
|
|
|
{ok, Filedata} = file:read_file(Filename), |
|
|
|
|
|
Elves = binary:split(Filedata, <<"\n\n">>, [global, trim_all]), |
|
|
|
|
|
Loads = lists:map(fun elf_load/1, Elves), |
|
|
|
|
|
{lists:max(Loads), ok}. |
|
|
|
|
|
|
|
|
|
|
|
elf_load([]) -> 0; |
|
|
|
|
|
elf_load([Load | Rest]) -> binary_to_integer(Load) + elf_load(Rest); |
|
|
|
|
|
elf_load(LoadString) when is_binary(LoadString) -> elf_load(binary:split(LoadString, <<$\n>>, [global, trim_all])). |
|
|
|
|
|
|
|
|
|
|
|
|