function found = strategy2 ( locker_num, locker_value, player_num, try_max )

%*****************************************************************************80
%
%% strategy2() uses strategy #2 on the locker problem.
%
%  Discussion:
%
%    Strategy 1 used a completely random list of lockers.
%    Strategy 2 uses a list that is random, except that there are no duplicates.
%    
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    16 November 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer locker_num: the number of lockers.
%
%    integer locker_value(locker_num): the number stored in each locker.
%
%    integer player_num: the number of players.
%
%    integer try_max: the maximum number of tries allowed.
%
%  Output:
%
%    integer found: the number of wallets that were found.
%
  if ( locker_num < try_max )
    try_max = locker_num;
  end

  found = 0;

  for player = 1 : player_num
%
%  Because fricking Ubuntu has an out of date Octave, I have
%  to use my own version of randsample().
%
    locker_01 = ksub_random3 ( locker_num, try_max );
    locker_indices = find ( locker_01 );
%   locker_indices = randsample ( locker_num, try_max );

    for trial = 1 : try_max
      locker = locker_indices(trial);
      if ( locker_value(locker) == player )
        found = found + 1;
        break
      end
    end

  end

  return
end

