Read all input supplied by HackerRank through standard input, then split it into non-empty lines:
input =
IO.read(:stdio, :eof)
|> String.split("\n", trim: true)
If each line contains one integer, parse the lines after splitting them:
input =
IO.read(:stdio, :eof)
|> String.split("\n", trim: true)
|> Enum.map(&String.to_integer/1)
The :eof option has been available since Elixir 1.13. When I wrote this note in October 2023, HackerRank used Elixir 1.8.2, so its editor required the older :all option instead:
input =
IO.read(:stdio, :all)
|> String.split("\n", trim: true)
Check the active Elixir version with System.version() before choosing between them. Online coding platforms can change their available runtimes independently.