function [B] = final_state_3(initial,action) % initial is the matrix to be updated after the operating action
A = genmatrix();                      % generate a matrix (9*9) where (i,j)th entry is 1 if i th and j th cells are adjacent and 0 otherwise
action = action';                     
action = reshape(action,9,1);         
action = (A*action);                  
action = reshape(action,3,3);
action = action';
B = mod((initial + action),2);        %computing the effect of action by using the logic given at http://www.ueda.info.waseda.ac.jp/~n-kato/lightsout/
return;
endfunction 