function parity = triangle_parity ( t )

%*****************************************************************************80
%
%% triangle_parity() computes the parity of a polyiamond from its triangle list.
%
%  Discussion:
%
%    The triangle list is a list of the IJK parallelogram triangles
%    that constitute the polyiamond.
%    If k = 0, the "ijk" triangle has vertices
%      (i-1,j-1), (i,j-1), (i-1,j).
%    If k = 1, the "ijk" triangle has vertices
%      (i,j), (i-1,j), (i,j-1).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer T(TN,3), the IJK parallelogram triangle coordinates of the 
%    triangles making up the polyiamond.  
%
%  Output:
%
%    integer PARITY: the number of Z=1 triangles minus the number of 
%    Z=0 triangles.
%
  k0 = sum ( t(:,3) == 0 );
  k1 = sum ( t(:,3) == 1 );
  parity = k1 - k0;

  return
end

