function subset_sum_backtrack_test_one ( s, n, v )

%*****************************************************************************80
%
%% subset_sum_backtrack_test_one() tests subset_sum_backtrack().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 November 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer S, the desired sum.
%
%    integer N, the number of values.
%
%    integer V(N), the values.
%    These must be nonnegative, and sorted in ascending order.  
%    Duplicate values are allowed.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'subset_sum_backtrack_test_one():\n' );
  fprintf ( 1, '  subset_sum_backtrack() uses backtracking to find\n' );
  fprintf ( 1, '  the "next" subset of the values V\n' );
  fprintf ( 1, '  which sum to the desired total S.\n' );

  more = false;
  u = zeros ( n, 1 );
  t = 0;
  
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Desired sum S = %d\n', s );
  fprintf ( 1, '  Number of targets = %d\n', n );
  fprintf ( 1, '  Targets:' );
  for i = 1 : n
    fprintf ( 1, ' %d', v(i) );
  end
  fprintf ( 1, '\n' );
  fprintf ( 1, '\n' );

  k = 0;
  
  while ( true )

    [ more, u, t ] = subset_sum_backtrack ( s, n, v, more, u, t );
    if ( ~ more )
      break
    end

    k = k + 1;
    fprintf ( 1, '  %d:  %d = ', k, s );
    plus = false;
    for i = 1 : n
      if ( u(i) ~= 0 )
        if ( plus ) 
          fprintf ( 1, '%s', '+' );
        end
        fprintf ( 1, '%d', v(i) );
        plus = true;
      end
    end
    fprintf ( 1, '\n' );
  end
  
  return
end
