We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
TIL: Read from STDIN in Elixir on HackerRank
Grab input data in HackerRank problems
Grab the input provided by HackerRank from STDIN with:
input = IO.read(:stdio, :all) |> String.split("\n")
If the input provided are numbers you might want to chain the above with:
input = IO.read(:stdio, :all) |> String.split("\n") |> Enum.map(&String.to_integer/1)
In recent versions of Elixir (v1.13.0 or above) you might
want to use
IO.read(:stdio, :eof) instead.
But HackerRank is running Elixir 1.8.2 which don’t
:eof option yet.
You can look at the Elixir version from within the REPL