from
Globs Game Player and Solver
by Husam Aldahiyat
Play and/or solve this fun and addictive game.
|
| surr(A,id)
|
function i = surr(A,id)
[a,b] = ind2sub(size(A),id);
a2 = repmat(a,1,4);
b2 = repmat(b,1,4);
b2(1) = b + 1;
b2(2) = b - 1;
a2(3) = a + 1;
a2(4) = a - 1;
d1 = ismember(a2,0) | ismember(a2,length(A)+1);
d2 = ismember(b2,0) | ismember(b2,length(A)+1);
a2(d1) = [];
b2(d1) = [];
a2(d2) = [];
b2(d2) = [];
i = sub2ind(size(A),a2,b2);
end
|
|
Contact us at files@mathworks.com