Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am ericdykstra on github.
  • I am ericd (https://keybase.io/ericd) on keybase.
  • I have a public key ASAv966Qu1nq0p8ibkcTXgdP5DYqGCMXbNA-FMJWrNKEQQo

To claim this, I am signing this object:

defmodule Day1 do
def main(file_path) do
file_path |> File.read! |> process |> IO.puts
end
def process(input) do
input
|> String.split(", ")
|> Enum.reduce(%{x: 0, y: 0, dir: "N"}, &reducer/2)
|> extract_answer
def change_state(xstate, d)
directions = "NESW"
i = "NESW".index(xstate)
if d == "R"
directions[i+1] ? directions[i+1] : "N"
else
directions[i-1] ? directions[i-1] : "W"
end
end