You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
453 B
16 lines
453 B
-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])).
|
|
|
|
|