HackerRank Template in Elixir

A colleague of mine sent me a link to a hacker rank challenge called Two Character

While giving it a try, I noticed no Elixir solution (yet!). Here's what the template solution looks like

defmodule Solution do
#Enter your code here. Read input from STDIN. Print output to STDOUT

Here is how I am structuring my answer.

defmodule Solution do
  def go() do
    num = input(:int)
    text = input(:string)
    IO.puts("INPUTS #{num} and #{text}")

  def input(:string), do: IO.read(:line) |> String.trim()
  def input(:int), do: input(:string) |> String.to_integer()

# Now run your code

When you run against HackerRank, you (properly get)

Reading and Writing for HackerRank

Notice the OUTPUT properly captured the input (i.e. the code is working as expected, but not yet as desired).

Now go forth and HackerRank!!!