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 |