*****************************************************************************
*       www.FindStat.org - The Combinatorial Statistic Finder               *
*                                                                           *
*       Copyright (C) 2019 The FindStatCrew <info@findstat.org>             *
*                                                                           *
*    This information is distributed in the hope that it will be useful,    *
*    but WITHOUT ANY WARRANTY; without even the implied warranty of         *
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                   *
*****************************************************************************

-----------------------------------------------------------------------------
Statistic identifier: St000252

-----------------------------------------------------------------------------
Collection: Binary trees

-----------------------------------------------------------------------------
Description: The number of nodes of degree 3 of a binary tree.

Equivalently, the number of internal triangles in the associated triangulation of an $(n+2)$-gon.

-----------------------------------------------------------------------------
References: [1]   Dochtermann, A. Face rings of cycles, associahedra, and standard Young tableaux [[arXiv:1503.06243]]

-----------------------------------------------------------------------------
Code:
def statistic(T):
    return sum(statistic_aux(C) for C in T)

def statistic_aux(T):
    if T == BinaryTree() or (T[0] == BinaryTree() and T[1] == BinaryTree()):
        return 0
    if T[0] == BinaryTree():
        return statistic_aux(T[1])
    if T[1] == BinaryTree():
        return statistic_aux(T[0])
    return 1 + statistic_aux(T[0]) + statistic_aux(T[1])
    


-----------------------------------------------------------------------------
Statistic values:

[.,.]                     => 0
[.,[.,.]]                 => 0
[[.,.],.]                 => 0
[.,[.,[.,.]]]             => 0
[.,[[.,.],.]]             => 0
[[.,.],[.,.]]             => 0
[[.,[.,.]],.]             => 0
[[[.,.],.],.]             => 0
[.,[.,[.,[.,.]]]]         => 0
[.,[.,[[.,.],.]]]         => 0
[.,[[.,.],[.,.]]]         => 1
[.,[[.,[.,.]],.]]         => 0
[.,[[[.,.],.],.]]         => 0
[[.,.],[.,[.,.]]]         => 0
[[.,.],[[.,.],.]]         => 0
[[.,[.,.]],[.,.]]         => 0
[[[.,.],.],[.,.]]         => 0
[[.,[.,[.,.]]],.]         => 0
[[.,[[.,.],.]],.]         => 0
[[[.,.],[.,.]],.]         => 1
[[[.,[.,.]],.],.]         => 0
[[[[.,.],.],.],.]         => 0
[.,[.,[.,[.,[.,.]]]]]     => 0
[.,[.,[.,[[.,.],.]]]]     => 0
[.,[.,[[.,.],[.,.]]]]     => 1
[.,[.,[[.,[.,.]],.]]]     => 0
[.,[.,[[[.,.],.],.]]]     => 0
[.,[[.,.],[.,[.,.]]]]     => 1
[.,[[.,.],[[.,.],.]]]     => 1
[.,[[.,[.,.]],[.,.]]]     => 1
[.,[[[.,.],.],[.,.]]]     => 1
[.,[[.,[.,[.,.]]],.]]     => 0
[.,[[.,[[.,.],.]],.]]     => 0
[.,[[[.,.],[.,.]],.]]     => 1
[.,[[[.,[.,.]],.],.]]     => 0
[.,[[[[.,.],.],.],.]]     => 0
[[.,.],[.,[.,[.,.]]]]     => 0
[[.,.],[.,[[.,.],.]]]     => 0
[[.,.],[[.,.],[.,.]]]     => 1
[[.,.],[[.,[.,.]],.]]     => 0
[[.,.],[[[.,.],.],.]]     => 0
[[.,[.,.]],[.,[.,.]]]     => 0
[[.,[.,.]],[[.,.],.]]     => 0
[[[.,.],.],[.,[.,.]]]     => 0
[[[.,.],.],[[.,.],.]]     => 0
[[.,[.,[.,.]]],[.,.]]     => 0
[[.,[[.,.],.]],[.,.]]     => 0
[[[.,.],[.,.]],[.,.]]     => 1
[[[.,[.,.]],.],[.,.]]     => 0
[[[[.,.],.],.],[.,.]]     => 0
[[.,[.,[.,[.,.]]]],.]     => 0
[[.,[.,[[.,.],.]]],.]     => 0
[[.,[[.,.],[.,.]]],.]     => 1
[[.,[[.,[.,.]],.]],.]     => 0
[[.,[[[.,.],.],.]],.]     => 0
[[[.,.],[.,[.,.]]],.]     => 1
[[[.,.],[[.,.],.]],.]     => 1
[[[.,[.,.]],[.,.]],.]     => 1
[[[[.,.],.],[.,.]],.]     => 1
[[[.,[.,[.,.]]],.],.]     => 0
[[[.,[[.,.],.]],.],.]     => 0
[[[[.,.],[.,.]],.],.]     => 1
[[[[.,[.,.]],.],.],.]     => 0
[[[[[.,.],.],.],.],.]     => 0
[.,[.,[.,[.,[.,[.,.]]]]]] => 0
[.,[.,[.,[.,[[.,.],.]]]]] => 0
[.,[.,[.,[[.,.],[.,.]]]]] => 1
[.,[.,[.,[[.,[.,.]],.]]]] => 0
[.,[.,[.,[[[.,.],.],.]]]] => 0
[.,[.,[[.,.],[.,[.,.]]]]] => 1
[.,[.,[[.,.],[[.,.],.]]]] => 1
[.,[.,[[.,[.,.]],[.,.]]]] => 1
[.,[.,[[[.,.],.],[.,.]]]] => 1
[.,[.,[[.,[.,[.,.]]],.]]] => 0
[.,[.,[[.,[[.,.],.]],.]]] => 0
[.,[.,[[[.,.],[.,.]],.]]] => 1
[.,[.,[[[.,[.,.]],.],.]]] => 0
[.,[.,[[[[.,.],.],.],.]]] => 0
[.,[[.,.],[.,[.,[.,.]]]]] => 1
[.,[[.,.],[.,[[.,.],.]]]] => 1
[.,[[.,.],[[.,.],[.,.]]]] => 2
[.,[[.,.],[[.,[.,.]],.]]] => 1
[.,[[.,.],[[[.,.],.],.]]] => 1
[.,[[.,[.,.]],[.,[.,.]]]] => 1
[.,[[.,[.,.]],[[.,.],.]]] => 1
[.,[[[.,.],.],[.,[.,.]]]] => 1
[.,[[[.,.],.],[[.,.],.]]] => 1
[.,[[.,[.,[.,.]]],[.,.]]] => 1
[.,[[.,[[.,.],.]],[.,.]]] => 1
[.,[[[.,.],[.,.]],[.,.]]] => 2
[.,[[[.,[.,.]],.],[.,.]]] => 1
[.,[[[[.,.],.],.],[.,.]]] => 1
[.,[[.,[.,[.,[.,.]]]],.]] => 0
[.,[[.,[.,[[.,.],.]]],.]] => 0
[.,[[.,[[.,.],[.,.]]],.]] => 1
[.,[[.,[[.,[.,.]],.]],.]] => 0
[.,[[.,[[[.,.],.],.]],.]] => 0
[.,[[[.,.],[.,[.,.]]],.]] => 1
[.,[[[.,.],[[.,.],.]],.]] => 1
[.,[[[.,[.,.]],[.,.]],.]] => 1
[.,[[[[.,.],.],[.,.]],.]] => 1
[.,[[[.,[.,[.,.]]],.],.]] => 0
[.,[[[.,[[.,.],.]],.],.]] => 0
[.,[[[[.,.],[.,.]],.],.]] => 1
[.,[[[[.,[.,.]],.],.],.]] => 0
[.,[[[[[.,.],.],.],.],.]] => 0
[[.,.],[.,[.,[.,[.,.]]]]] => 0
[[.,.],[.,[.,[[.,.],.]]]] => 0
[[.,.],[.,[[.,.],[.,.]]]] => 1
[[.,.],[.,[[.,[.,.]],.]]] => 0
[[.,.],[.,[[[.,.],.],.]]] => 0
[[.,.],[[.,.],[.,[.,.]]]] => 1
[[.,.],[[.,.],[[.,.],.]]] => 1
[[.,.],[[.,[.,.]],[.,.]]] => 1
[[.,.],[[[.,.],.],[.,.]]] => 1
[[.,.],[[.,[.,[.,.]]],.]] => 0
[[.,.],[[.,[[.,.],.]],.]] => 0
[[.,.],[[[.,.],[.,.]],.]] => 1
[[.,.],[[[.,[.,.]],.],.]] => 0
[[.,.],[[[[.,.],.],.],.]] => 0
[[.,[.,.]],[.,[.,[.,.]]]] => 0
[[.,[.,.]],[.,[[.,.],.]]] => 0
[[.,[.,.]],[[.,.],[.,.]]] => 1
[[.,[.,.]],[[.,[.,.]],.]] => 0
[[.,[.,.]],[[[.,.],.],.]] => 0
[[[.,.],.],[.,[.,[.,.]]]] => 0
[[[.,.],.],[.,[[.,.],.]]] => 0
[[[.,.],.],[[.,.],[.,.]]] => 1
[[[.,.],.],[[.,[.,.]],.]] => 0
[[[.,.],.],[[[.,.],.],.]] => 0
[[.,[.,[.,.]]],[.,[.,.]]] => 0
[[.,[.,[.,.]]],[[.,.],.]] => 0
[[.,[[.,.],.]],[.,[.,.]]] => 0
[[.,[[.,.],.]],[[.,.],.]] => 0
[[[.,.],[.,.]],[.,[.,.]]] => 1
[[[.,.],[.,.]],[[.,.],.]] => 1
[[[.,[.,.]],.],[.,[.,.]]] => 0
[[[.,[.,.]],.],[[.,.],.]] => 0
[[[[.,.],.],.],[.,[.,.]]] => 0
[[[[.,.],.],.],[[.,.],.]] => 0
[[.,[.,[.,[.,.]]]],[.,.]] => 0
[[.,[.,[[.,.],.]]],[.,.]] => 0
[[.,[[.,.],[.,.]]],[.,.]] => 1
[[.,[[.,[.,.]],.]],[.,.]] => 0
[[.,[[[.,.],.],.]],[.,.]] => 0
[[[.,.],[.,[.,.]]],[.,.]] => 1
[[[.,.],[[.,.],.]],[.,.]] => 1
[[[.,[.,.]],[.,.]],[.,.]] => 1
[[[[.,.],.],[.,.]],[.,.]] => 1
[[[.,[.,[.,.]]],.],[.,.]] => 0
[[[.,[[.,.],.]],.],[.,.]] => 0
[[[[.,.],[.,.]],.],[.,.]] => 1
[[[[.,[.,.]],.],.],[.,.]] => 0
[[[[[.,.],.],.],.],[.,.]] => 0
[[.,[.,[.,[.,[.,.]]]]],.] => 0
[[.,[.,[.,[[.,.],.]]]],.] => 0
[[.,[.,[[.,.],[.,.]]]],.] => 1
[[.,[.,[[.,[.,.]],.]]],.] => 0
[[.,[.,[[[.,.],.],.]]],.] => 0
[[.,[[.,.],[.,[.,.]]]],.] => 1
[[.,[[.,.],[[.,.],.]]],.] => 1
[[.,[[.,[.,.]],[.,.]]],.] => 1
[[.,[[[.,.],.],[.,.]]],.] => 1
[[.,[[.,[.,[.,.]]],.]],.] => 0
[[.,[[.,[[.,.],.]],.]],.] => 0
[[.,[[[.,.],[.,.]],.]],.] => 1
[[.,[[[.,[.,.]],.],.]],.] => 0
[[.,[[[[.,.],.],.],.]],.] => 0
[[[.,.],[.,[.,[.,.]]]],.] => 1
[[[.,.],[.,[[.,.],.]]],.] => 1
[[[.,.],[[.,.],[.,.]]],.] => 2
[[[.,.],[[.,[.,.]],.]],.] => 1
[[[.,.],[[[.,.],.],.]],.] => 1
[[[.,[.,.]],[.,[.,.]]],.] => 1
[[[.,[.,.]],[[.,.],.]],.] => 1
[[[[.,.],.],[.,[.,.]]],.] => 1
[[[[.,.],.],[[.,.],.]],.] => 1
[[[.,[.,[.,.]]],[.,.]],.] => 1
[[[.,[[.,.],.]],[.,.]],.] => 1
[[[[.,.],[.,.]],[.,.]],.] => 2
[[[[.,[.,.]],.],[.,.]],.] => 1
[[[[[.,.],.],.],[.,.]],.] => 1
[[[.,[.,[.,[.,.]]]],.],.] => 0
[[[.,[.,[[.,.],.]]],.],.] => 0
[[[.,[[.,.],[.,.]]],.],.] => 1
[[[.,[[.,[.,.]],.]],.],.] => 0
[[[.,[[[.,.],.],.]],.],.] => 0
[[[[.,.],[.,[.,.]]],.],.] => 1
[[[[.,.],[[.,.],.]],.],.] => 1
[[[[.,[.,.]],[.,.]],.],.] => 1
[[[[[.,.],.],[.,.]],.],.] => 1
[[[[.,[.,[.,.]]],.],.],.] => 0
[[[[.,[[.,.],.]],.],.],.] => 0
[[[[[.,.],[.,.]],.],.],.] => 1
[[[[[.,[.,.]],.],.],.],.] => 0
[[[[[[.,.],.],.],.],.],.] => 0

-----------------------------------------------------------------------------
Created: May 27, 2015 at 15:00 by Anton Dochtermann

-----------------------------------------------------------------------------
Last Updated: Aug 05, 2016 at 20:11 by Martin Rubey