function L = lo_light_chase ( L )

%*****************************************************************************80
%
%% lo_light_chase() chases lights to the bottom row.
%
%  Discussion:
%
%    For a given 5x5 Lights Out configuration L, we can always push buttons
%    in such a way that all the lights are out except for some in the
%    bottom row.  This is called "light chasing", and is the first step
%    in determining if the configuration is solvable or not.
%
%    The important result is the status of the bottom row at the end.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 November 2024
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    logical L(5,5): the starting configuration.
%
%  Output:
%
%    logical L(5,5): the configuration after light chasing.  Lights may
%    be illuminated only in the bottom row.
%
  m = 5;
  n = 5;
  push = 0;

  for i = 1 : m - 1
    for j = 1 : n
%
%  If light is on, press the button just below it.
%
      if ( L(i,j) )
        push = push + 1;
        L = lo_update ( L, i + 1, j );
      end
    end
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Light chasing required %d button pushes.\n', push );

  return
end

