Hacker Rank And Elixir

So I was just working through some of the materials over at HackerRank and I can’t quite figure out what they’re doing. I mean they give you a template

defmodule Solution do
end

And you have to write the code inline in the module, like this:

defmodule Solution do
   IO.puts("Hello World")
end

I can’t figure out what it’s doing to get that code to work. It’s not legal Elixir syntax (or is it?) so what’s the trick? I’m not trying to learn anything from HR because I’d like to think I have a good grasp of Elixir already. This strikes me as a poor resource for anyone trying to learn Elixir though.

Well it is legal, but it will be executed during compilation, not something you can easily assert.

They don’t give you the name of the function and which parameters it should have? It is in neither the tests provided? (I don’t remember if they provide some).

If you like to learn solving these puzzles I prefer Codewars. If not a great resource to hands on learning is Exercism

2 Likes