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

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

-----------------------------------------------------------------------------
Description: The Andrews-Garvan crank of a partition.

If $\pi$ is a partition, let $l(\pi)$ be its length (number of parts), $\omega(\pi)$ be the number of parts equal to 1, and $\mu(\pi)$ be the number of parts larger than $\omega(\pi)$. The crank is then defined by

$$
c(\pi) = 
\begin{cases}
l(\pi) &\text{if \(\omega(\pi)=0\)}\\
\mu(\pi) - \omega(\pi) &\text{otherwise}.
\end{cases}
$$

This statistic was defined in [1] to explain Ramanujan's partition congruence $$p(11n+6) \equiv 0 \pmod{11}$$ in the same way as the Dyson rank ([[St000145]]) explains the congruences $$p(5n+4) \equiv 0 \pmod{5}$$ and $$p(7n+5) \equiv 0 \pmod{7}.$$

-----------------------------------------------------------------------------
References: [1]   Andrews, G. E., Garvan, F. G. Dyson's crank of a partition [[MathSciNet:0929094]]
[2]   [[wikipedia:Ramanujan's congruences]]

-----------------------------------------------------------------------------
Code:
def statistic(p):
    nb_ones = p.to_list().count(1)
    if nb_ones == 0:
        return len(p)
    else:
        return len([i for i in p if i > nb_ones]) - nb_ones

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

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

-----------------------------------------------------------------------------
Created: Jul 05, 2013 at 14:36 by Olivier Mallet

-----------------------------------------------------------------------------
Last Updated: Nov 29, 2021 at 10:47 by Martin Rubey