function counts = candy_count_vector ( c, n )

%*****************************************************************************80
%
%% candy_count_vector() counts candy types in a vector.
%
%  Discussion:
%
%    We are given a box of candy containing C distinct types, and
%    asked to report how many of each type there are.
%
%    In this case, the box is a vector, which can hold N items,
%    indexed 1 through N.
%
%    The candy types occur in sequence, that is, the first item is
%    candy type 1, item 2 is type 2, item C is type C.  Then
%    the types repeat, so item C+1 is type 1, and so on.
%
%    This version of the problem is simple to understand and solve.
%    The problem is more interesting if the candy is stored in a 
%    rectangular array, or a 3-dimensional box.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 June 2024
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer c: the number of types of candy.
%
%    integer n: the number of columns in the candy box.
%
%  Output:
%
%    integer counts(c): the number of each type of candy in the box.
%

%
%  N = N_MIN * C + N_REM
%
  n_min = floor ( n / c );
%
%  Everybody gets at least N_MIN.
%
  counts = n_min * ones ( 1, c );
%
%  There are N_REM candies remaining.
%  Give 1 each to types 1 through N_REM.
%
  n_rem = n - n_min * c;

  counts(1:n_rem) = counts(1:n_rem) + 1;

  return
end

