         hops: state.hops + 1
     }
 
-    Map.update(new_state, :cost, 0, fn _ -> State.cost(new_state) end)
+    new_state
+    |> Map.update(:cost, 0, fn _ -> State.cost(new_state) end)
+    |> Map.update(:hash, "", fn _ -> State.hash(new_state) end)
   end
 
   def is_end?(%State{} = state) do

          floors: list(any()),
          elevator_location: integer(),
          hops: integer(),
          cost: integer()
        }
  @type direction() :: :up | :down
  defstruct [:floors, :elevator_location, hops: 0, cost: 999]

  # apply the states
  @spec apply(t(), {direction(), list(any())}) :: t()

        hops: state.hops + 1
    }

    new_state
    |> Map.update(:cost, 0, fn _ -> State.cost(new_state) end)
    |> Map.update(:hash, "", fn _ -> State.hash(new_state) end)
  end

  def apply(state, {:down, items}) do
