Erlang - Hacker rank solutions