             :cont,
             %{
               # Add the steps we've walked to the set of visited nodes
-              visited: MapSet.union(acc.visited, MapSet.new(w)),
+              visited: MapSet.union(acc.visited, MapSet.new(path)),
               position: new_position,
               direction: new_direction
             }

    )
  end

  def integers(start, count) do
    Stream.iterate(start, &(&1+1)) |> Enum.take(count)
  end
 
  @doc """
  Walk from start to finish, which must be on a horizontal or vertical line from start.
  Returns the steps taken
  """
  def walk(start, finish) do
    sign =
    if start.x == finish.x do
      if start.y < finish.y, do: 1, else: -1
    else
      if start.x < finish.x, do: 1, else: -1
    end

    if start.x == finish.x do
      integers(1, abs(finish.y - start.y))
      |> Enum.map(fn(y) -> %Vec{x: start.x, y: start.y + y * sign} end)
    else
      integers(1, abs(finish.x - start.x))
      |> Enum.map(fn(x) -> %Vec{x: start.x + x * sign, y: start.y} end)
    end
  end

  @doc """


defmodule App do

  @n %Vec{y: 1}
  @s %Vec{y: -1}
  @e %Vec{x: 1}
  @w %Vec{x: -1}

  def turn(@n,  "R"), do: @e
  def turn(@e,  "R"), do: @s
  def turn(@s,  "R"), do: @w
  def turn(@w,  "R"), do: @n
  def turn(@n,  "L"), do: @w
  def turn(@e,  "L"), do: @n
  def turn(@s,  "L"), do: @e
  def turn(@w,  "L"), do: @s

  def parse_move_list(input) do
    input
