Skip to content

Instantly share code, notes, and snippets.

@lukesarnacki
Created January 18, 2019 13:23
Show Gist options
  • Save lukesarnacki/6face740d5d9fcdb33f141622c7fbb32 to your computer and use it in GitHub Desktop.
Save lukesarnacki/6face740d5d9fcdb33f141622c7fbb32 to your computer and use it in GitHub Desktop.
Elixir Advent of Code template

Run the code:

elixir dayx.exs input.txt

Run the tests:

elixir dayx.exs --test
defmodule DayX do
def call(input) do
input
|> String.split("\n", trim: true)
end
end
case System.argv() do
["--test"] ->
ExUnit.start()
defmodule DayXTest do
use ExUnit.Case
import DayX
test "" do
assert call("""
""") == []
end
end
[input_file] ->
input_file
|> File.read!()
|> DayX.call
|> IO.puts
_ ->
IO.puts :stderr, "wrong argument"
System.halt(1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment