function [b] = adj(k,l)                    %this function returns 1 if k th and l th cells are adjacent and zero otherwise
row_k = floor(k/3);                        %computing the corresponding row and column corresponding to k th and l th cell
row_l = floor(l/3);
col_k = mod(k,3);
col_l = mod(l,3);
if((row_k-row_l)^2+(col_k-col_l)^2 <= 1)   
b = 1;
else
b = 0;
endif
endfunction
