function [ l_length, l, x_length, x ] = place ( l_length, l, x_length, x )

%*****************************************************************************80
%
%% PLACE tries to place the next point for the partial digest problem.
%
%  Discussion:
%
%    Note that this is a recursive subroutine.  A solution to the
%    partial digest problem is sought by calling this routine repeatedly.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    10 January 2018
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Pavel Pevzner,
%    Computational Molecular Biology,
%    MIT Press, 2000,
%    ISBN: 0-262-16197-4,
%    LC: QH506.P47.
%
%  Parameters:
%
%    Input/output, integer L_LENGTH, the number of entries in L.
%
%    Input/output, integer L(L_LENGTH), the array of distances.

%    Input/output, integer X_LENGTH, the number of entries in X.
%
%    Input/output, integer X(X_LENGTH), the current partial solution.
%

%
%  Are we done?
%
  if ( l_length <= 0 )
    i4vec_print ( x_length, x, '  Solution:' );
    return
  end
%
%  Find the maximum remaining distance.
%
  [ l, y ] = i4vec_max_last ( l_length, l );
%
%  We can add a point at Y if L contains all the distances from Y to
%  the current X's.
%
  [ success, l ] = find_distances ( l_length, l, x_length, x, y );

  if ( success )
    l_length2 = l_length - x_length;
    x_length = x_length + 1;
    x(x_length) = y;
    [ l_length2, l, x_length, x ] = place ( l_length2, l, x_length, x );
    x_length = x_length - 1;
  end
%
%  We must also consider the case where Y represents the distance
%  to X(2), not X(1).
%
  y = x(2) - y;

  [ success, l ] = find_distances ( l_length, l, x_length, x, y );

  if ( success )
    l_length2 = l_length - x_length;
    x_length = x_length + 1;
    x(x_length) = y;
    [ l_length2, l, x_length, x ] = place ( l_length2, l, x_length, x );
    x_length = x_length - 1;
  end

  return
end