function L = lo_update ( L, i, j );

%*****************************************************************************80
%
%% lo_update() updates the Lights Out status after (I,J) is pushed.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    08 November 2017
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    logical L(M,N), true where lights are on.
%
%    integer I, J, the row and column of the light that was pushed.
%
%  Output:
%
%    logical L(M,N), the updated Lights Out status.
%
  m = 5;
  n = 5;
%
%  Reverse the (i,j) light.
%
  L(i,j) = ~ L(i,j);

  if ( 1 < i )
    L(i-1,j) = ~ L(i-1,j);
  end
  if ( i < m )
    L(i+1,j) = ~ L(i+1,j);
  end
  if ( 1 < j )
    L(i,j-1) = ~ L(i,j-1);
  end
  if ( j < n )
    L(i,j+1) = ~ L(i,j+1);
  end

  return
end

