*****************************************************************************
*       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: St000478

-----------------------------------------------------------------------------
Collection: Integer partitions

-----------------------------------------------------------------------------
Description: Another weight of a partition according to Alladi.

According to Theorem 3.4 (Alladi 2012) in [1]
$$
\sum_{\pi\in GG_1(r)} w_1(\pi)
$$
equals the number of partitions of $r$ whose odd parts are all distinct.  $GG_1(r)$ is the set of partitions of $r$ where consecutive entries differ by at least $2$, and consecutive even entries differ by at least $4$.

-----------------------------------------------------------------------------
References: [1]   Berkovich, A., Kemal Uncu, A. Variation on a theme of Nathan Fine. New weighted partition identities [[arXiv:1605.00291]]

-----------------------------------------------------------------------------
Code:
def statistic(pi):
    """
    sage: statistic(Partition([18,12,7,5]))
    12

    Theorem (3.12) of http://arxiv.org/pdf/1605.00291.pdf:
    sage: r=10; DO = [1 for pi in Partitions(r) if len(set(p for p in pi if is_odd(p))) == len([p for p in pi if is_odd(p)])]
    sage: GG1 = [pi for pi in Partitions(r, max_slope=-2) if all(pi[j]-pi[j+1] != 2 for j in range(len(pi)-1) if is_even(pi[j]))]
    sage: sum(statistic(pi) for pi in GG1) == len(DO)
    True
    """
    def delta_even(p):
        if is_even(p):
            return 1
        else:
            return 0

    return (pi[-1] + 1 - delta_even(pi[-1]))/2 * prod((pi[i] - pi[i+1] - delta_even(pi[i]) - delta_even(pi[i+1]))/2 for i in range(len(pi)-1))


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

[2]                       => 1
[1,1]                     => 0
[3]                       => 2
[2,1]                     => 0
[1,1,1]                   => 0
[4]                       => 2
[3,1]                     => 1
[2,2]                     => -1
[2,1,1]                   => 0
[1,1,1,1]                 => 0
[5]                       => 3
[4,1]                     => 1
[3,2]                     => 0
[3,1,1]                   => 0
[2,2,1]                   => 0
[2,1,1,1]                 => 0
[1,1,1,1,1]               => 0
[6]                       => 3
[5,1]                     => 2
[4,2]                     => 0
[4,1,1]                   => 0
[3,3]                     => 0
[3,2,1]                   => 0
[3,1,1,1]                 => 0
[2,2,2]                   => 1
[2,2,1,1]                 => 0
[2,1,1,1,1]               => 0
[1,1,1,1,1,1]             => 0
[7]                       => 4
[6,1]                     => 2
[5,2]                     => 1
[5,1,1]                   => 0
[4,3]                     => 0
[4,2,1]                   => 0
[4,1,1,1]                 => 0
[3,3,1]                   => 0
[3,2,2]                   => 0
[3,2,1,1]                 => 0
[3,1,1,1,1]               => 0
[2,2,2,1]                 => 0
[2,2,1,1,1]               => 0
[2,1,1,1,1,1]             => 0
[1,1,1,1,1,1,1]           => 0
[8]                       => 4
[7,1]                     => 3
[6,2]                     => 1
[6,1,1]                   => 0
[5,3]                     => 2
[5,2,1]                   => 0
[5,1,1,1]                 => 0
[4,4]                     => -2
[4,3,1]                   => 0
[4,2,2]                   => 0
[4,2,1,1]                 => 0
[4,1,1,1,1]               => 0
[3,3,2]                   => 0
[3,3,1,1]                 => 0
[3,2,2,1]                 => 0
[3,2,1,1,1]               => 0
[3,1,1,1,1,1]             => 0
[2,2,2,2]                 => -1
[2,2,2,1,1]               => 0
[2,2,1,1,1,1]             => 0
[2,1,1,1,1,1,1]           => 0
[1,1,1,1,1,1,1,1]         => 0
[9]                       => 5
[8,1]                     => 3
[7,2]                     => 2
[7,1,1]                   => 0
[6,3]                     => 2
[6,2,1]                   => 0
[6,1,1,1]                 => 0
[5,4]                     => 0
[5,3,1]                   => 1
[5,2,2]                   => -1
[5,2,1,1]                 => 0
[5,1,1,1,1]               => 0
[4,4,1]                   => -1
[4,3,2]                   => 0
[4,3,1,1]                 => 0
[4,2,2,1]                 => 0
[4,2,1,1,1]               => 0
[4,1,1,1,1,1]             => 0
[3,3,3]                   => 0
[3,3,2,1]                 => 0
[3,3,1,1,1]               => 0
[3,2,2,2]                 => 0
[3,2,2,1,1]               => 0
[3,2,1,1,1,1]             => 0
[3,1,1,1,1,1,1]           => 0
[2,2,2,2,1]               => 0
[2,2,2,1,1,1]             => 0
[2,2,1,1,1,1,1]           => 0
[2,1,1,1,1,1,1,1]         => 0
[1,1,1,1,1,1,1,1,1]       => 0
[10]                      => 5
[9,1]                     => 4
[8,2]                     => 2
[8,1,1]                   => 0
[7,3]                     => 4
[7,2,1]                   => 0
[7,1,1,1]                 => 0
[6,4]                     => 0
[6,3,1]                   => 1
[6,2,2]                   => -1
[6,2,1,1]                 => 0
[6,1,1,1,1]               => 0
[5,5]                     => 0
[5,4,1]                   => 0
[5,3,2]                   => 0
[5,3,1,1]                 => 0
[5,2,2,1]                 => 0
[5,2,1,1,1]               => 0
[5,1,1,1,1,1]             => 0
[4,4,2]                   => 0
[4,4,1,1]                 => 0
[4,3,3]                   => 0
[4,3,2,1]                 => 0
[4,3,1,1,1]               => 0
[4,2,2,2]                 => 0
[4,2,2,1,1]               => 0
[4,2,1,1,1,1]             => 0
[4,1,1,1,1,1,1]           => 0
[3,3,3,1]                 => 0
[3,3,2,2]                 => 0
[3,3,2,1,1]               => 0
[3,3,1,1,1,1]             => 0
[3,2,2,2,1]               => 0
[3,2,2,1,1,1]             => 0
[3,2,1,1,1,1,1]           => 0
[3,1,1,1,1,1,1,1]         => 0
[2,2,2,2,2]               => 1
[2,2,2,2,1,1]             => 0
[2,2,2,1,1,1,1]           => 0
[2,2,1,1,1,1,1,1]         => 0
[2,1,1,1,1,1,1,1,1]       => 0
[1,1,1,1,1,1,1,1,1,1]     => 0
[11]                      => 6
[10,1]                    => 4
[9,2]                     => 3
[9,1,1]                   => 0
[8,3]                     => 4
[8,2,1]                   => 0
[8,1,1,1]                 => 0
[7,4]                     => 2
[7,3,1]                   => 2
[7,2,2]                   => -2
[7,2,1,1]                 => 0
[7,1,1,1,1]               => 0
[6,5]                     => 0
[6,4,1]                   => 0
[6,3,2]                   => 0
[6,3,1,1]                 => 0
[6,2,2,1]                 => 0
[6,2,1,1,1]               => 0
[6,1,1,1,1,1]             => 0
[5,5,1]                   => 0
[5,4,2]                   => 0
[5,4,1,1]                 => 0
[5,3,3]                   => 0
[5,3,2,1]                 => 0
[5,3,1,1,1]               => 0
[5,2,2,2]                 => 1
[5,2,2,1,1]               => 0
[5,2,1,1,1,1]             => 0
[5,1,1,1,1,1,1]           => 0
[4,4,3]                   => 0
[4,4,2,1]                 => 0
[4,4,1,1,1]               => 0
[4,3,3,1]                 => 0
[4,3,2,2]                 => 0
[4,3,2,1,1]               => 0
[4,3,1,1,1,1]             => 0
[4,2,2,2,1]               => 0
[4,2,2,1,1,1]             => 0
[4,2,1,1,1,1,1]           => 0
[4,1,1,1,1,1,1,1]         => 0
[3,3,3,2]                 => 0
[3,3,3,1,1]               => 0
[3,3,2,2,1]               => 0
[3,3,2,1,1,1]             => 0
[3,3,1,1,1,1,1]           => 0
[3,2,2,2,2]               => 0
[3,2,2,2,1,1]             => 0
[3,2,2,1,1,1,1]           => 0
[3,2,1,1,1,1,1,1]         => 0
[3,1,1,1,1,1,1,1,1]       => 0
[2,2,2,2,2,1]             => 0
[2,2,2,2,1,1,1]           => 0
[2,2,2,1,1,1,1,1]         => 0
[2,2,1,1,1,1,1,1,1]       => 0
[2,1,1,1,1,1,1,1,1,1]     => 0
[1,1,1,1,1,1,1,1,1,1,1]   => 0
[12]                      => 6
[11,1]                    => 5
[10,2]                    => 3
[10,1,1]                  => 0
[9,3]                     => 6
[9,2,1]                   => 0
[9,1,1,1]                 => 0
[8,4]                     => 2
[8,3,1]                   => 2
[8,2,2]                   => -2
[8,2,1,1]                 => 0
[8,1,1,1,1]               => 0
[7,5]                     => 3
[7,4,1]                   => 1
[7,3,2]                   => 0
[7,3,1,1]                 => 0
[7,2,2,1]                 => 0
[7,2,1,1,1]               => 0
[7,1,1,1,1,1]             => 0
[6,6]                     => -3
[6,5,1]                   => 0
[6,4,2]                   => 0
[6,4,1,1]                 => 0
[6,3,3]                   => 0
[6,3,2,1]                 => 0
[6,3,1,1,1]               => 0
[6,2,2,2]                 => 1
[6,2,2,1,1]               => 0
[6,2,1,1,1,1]             => 0
[6,1,1,1,1,1,1]           => 0
[5,5,2]                   => 0
[5,5,1,1]                 => 0
[5,4,3]                   => 0
[5,4,2,1]                 => 0
[5,4,1,1,1]               => 0
[5,3,3,1]                 => 0
[5,3,2,2]                 => 0
[5,3,2,1,1]               => 0
[5,3,1,1,1,1]             => 0
[5,2,2,2,1]               => 0
[5,2,2,1,1,1]             => 0
[5,2,1,1,1,1,1]           => 0
[5,1,1,1,1,1,1,1]         => 0
[4,4,4]                   => 2
[4,4,3,1]                 => 0
[4,4,2,2]                 => 0
[4,4,2,1,1]               => 0
[4,4,1,1,1,1]             => 0
[4,3,3,2]                 => 0
[4,3,3,1,1]               => 0
[4,3,2,2,1]               => 0
[4,3,2,1,1,1]             => 0
[4,3,1,1,1,1,1]           => 0
[4,2,2,2,2]               => 0
[4,2,2,2,1,1]             => 0
[4,2,2,1,1,1,1]           => 0
[4,2,1,1,1,1,1,1]         => 0
[4,1,1,1,1,1,1,1,1]       => 0
[3,3,3,3]                 => 0
[3,3,3,2,1]               => 0
[3,3,3,1,1,1]             => 0
[3,3,2,2,2]               => 0
[3,3,2,2,1,1]             => 0
[3,3,2,1,1,1,1]           => 0
[3,3,1,1,1,1,1,1]         => 0
[3,2,2,2,2,1]             => 0
[3,2,2,2,1,1,1]           => 0
[3,2,2,1,1,1,1,1]         => 0
[3,2,1,1,1,1,1,1,1]       => 0
[3,1,1,1,1,1,1,1,1,1]     => 0
[2,2,2,2,2,2]             => -1
[2,2,2,2,2,1,1]           => 0
[2,2,2,2,1,1,1,1]         => 0
[2,2,2,1,1,1,1,1,1]       => 0
[2,2,1,1,1,1,1,1,1,1]     => 0
[2,1,1,1,1,1,1,1,1,1,1]   => 0
[1,1,1,1,1,1,1,1,1,1,1,1] => 0

-----------------------------------------------------------------------------
Created: May 03, 2016 at 12:34 by Martin Rubey

-----------------------------------------------------------------------------
Last Updated: May 03, 2016 at 15:48 by Martin Rubey