function [x, y] = RandomWalk2D_v2(N)
% Simulate a 2D random walk in an (2N+1)-by-(2N+1) grid.
% N is a positive integer.
% Walk starts from the middle and continues until the an edge, abs(N),
% is reached.
% x and y are row vectors with the property that (x(k),y(k)) is the
% location of the token after k hops, k=1:length(x).
% Initializations...
k=0; xc=0; yc=0;
% Vectors to represent change in four directions
% N E S W
deltaX= [ 0 1 0 -1];
deltaY= [ 1 0 -1 0];
% In general, (xc,yc) is the location after k hops.
while abs(xc)