-
-
Save manuelgeek/ddc26a2420475ee5d7862c9196ec35c9 to your computer and use it in GitHub Desktop.
How to read from STDIN in Elixir (for HackerRank)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Solution do | |
#Enter your code here. Read input from STDIN. Print output to STDOUT | |
end | |
array_length = IO.read(:stdio, :line) | |
array = IO.read(:stdio, :line) | |
array_length | |
|> String.trim | |
|> String.to_integer | |
|> IO.puts | |
array | |
|> String.split(" ") | |
|> Enum.map(fn n -> String.to_integer(n) end) | |
|> IO.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment