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

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

-----------------------------------------------------------------------------
Description: Number of permutations whose sorted list of non zero multiplicities of the Lehmer code is the given partition.


-----------------------------------------------------------------------------
References: [1]   Hivert, F., Novelli, J.-C., Thibon, J.-Y. Multivariate generalizations of the Foata-Schützenberger equidistribution [[MathSciNet:2509639]] [[arXiv:math/0605060]]

-----------------------------------------------------------------------------
Code:
import collections
def part_of_perm(p):
    c = p.to_lehmer_code()
    return Partition(sorted([c.count(i) for i in range(len(p)) if i in c])[::-1])

@cached_function
def stat(N):
    res = collections.defaultdict(int)
    for p in Permutations(N):
        res[part_of_perm(p)] += 1
    return dict(res)

def statistic(L):
    return stat(L.size())[L]

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

[]                    => 1
[1]                   => 1
[2]                   => 1
[1,1]                 => 1
[3]                   => 1
[2,1]                 => 4
[1,1,1]               => 1
[4]                   => 1
[3,1]                 => 7
[2,2]                 => 4
[2,1,1]               => 11
[1,1,1,1]             => 1
[5]                   => 1
[4,1]                 => 11
[3,2]                 => 15
[3,1,1]               => 32
[2,2,1]               => 34
[2,1,1,1]             => 26
[1,1,1,1,1]           => 1
[6]                   => 1
[5,1]                 => 16
[4,2]                 => 26
[4,1,1]               => 76
[3,3]                 => 15
[3,2,1]               => 192
[3,1,1,1]             => 122
[2,2,2]               => 34
[2,2,1,1]             => 180
[2,1,1,1,1]           => 57
[1,1,1,1,1,1]         => 1
[7]                   => 1
[6,1]                 => 22
[5,2]                 => 42
[5,1,1]               => 156
[4,3]                 => 56
[4,2,1]               => 474
[4,1,1,1]             => 426
[3,3,1]               => 267
[3,2,2]               => 294
[3,2,1,1]             => 1494
[3,1,1,1,1]           => 423
[2,2,2,1]             => 496
[2,2,1,1,1]           => 768
[2,1,1,1,1,1]         => 120
[1,1,1,1,1,1,1]       => 1
[8]                   => 1
[7,1]                 => 29
[6,2]                 => 64
[6,1,1]               => 288
[5,3]                 => 98
[5,2,1]               => 1038
[5,1,1,1]             => 1206
[4,4]                 => 56
[4,3,1]               => 1344
[4,2,2]               => 768
[4,2,1,1]             => 5142
[4,1,1,1,1]           => 2127
[3,3,2]               => 855
[3,3,1,1]             => 2829
[3,2,2,1]             => 5946
[3,2,1,1,1]           => 9204
[3,1,1,1,1,1]         => 1389
[2,2,2,2]             => 496
[2,2,2,1,1]           => 4288
[2,2,1,1,1,1]         => 2904
[2,1,1,1,1,1,1]       => 247
[1,1,1,1,1,1,1,1]     => 1
[9]                   => 1
[8,1]                 => 37
[7,2]                 => 93
[7,1,1]               => 491
[6,3]                 => 162
[6,2,1]               => 2062
[6,1,1,1]             => 2934
[5,4]                 => 210
[5,3,1]               => 3068
[5,2,2]               => 1806
[5,2,1,1]             => 14988
[5,1,1,1,1]           => 8157
[4,4,1]               => 1736
[4,3,2]               => 4590
[4,3,1,1]             => 18864
[4,2,2,1]             => 20838
[4,2,1,1,1]           => 43422
[4,1,1,1,1,1]         => 9897
[3,3,3]               => 855
[3,3,2,1]             => 22680
[3,3,1,1,1]           => 23349
[3,2,2,2]             => 7930
[3,2,2,1,1]           => 70206
[3,2,1,1,1,1]         => 49569
[3,1,1,1,1,1,1]       => 4414
[2,2,2,2,1]           => 11056
[2,2,2,1,1,1]         => 28768
[2,2,1,1,1,1,1]       => 10194
[2,1,1,1,1,1,1,1]     => 502
[1,1,1,1,1,1,1,1,1]   => 1
[10]                  => 1
[9,1]                 => 46
[8,2]                 => 130
[8,1,1]               => 787
[7,3]                 => 255
[7,2,1]               => 3788
[7,1,1,1]             => 6371
[6,4]                 => 372
[6,3,1]               => 6426
[6,2,2]               => 3868
[6,2,1,1]             => 38224
[6,1,1,1,1]           => 25761
[5,5]                 => 210
[5,4,1]               => 8220
[5,3,2]               => 11270
[5,3,1,1]             => 55328
[5,2,2,1]             => 63456
[5,2,1,1,1]           => 165978
[5,1,1,1,1,1]         => 50682
[4,4,2]               => 6326
[4,4,1,1]             => 31016
[4,3,3]               => 7155
[4,3,2,1]             => 156894
[4,3,1,1,1]           => 203304
[4,2,2,2]             => 28768
[4,2,2,1,1]           => 325500
[4,2,1,1,1,1]         => 316164
[4,1,1,1,1,1,1]       => 44002
[3,3,3,1]             => 28665
[3,3,2,2]             => 46470
[3,3,2,1,1]           => 346539
[3,3,1,1,1,1]         => 166314
[3,2,2,2,1]           => 232216
[3,2,2,1,1,1]         => 635610
[3,2,1,1,1,1,1]       => 245148
[3,1,1,1,1,1,1,1]     => 13744
[2,2,2,2,2]           => 11056
[2,2,2,2,1,1]         => 141584
[2,2,2,1,1,1,1]       => 166042
[2,2,1,1,1,1,1,1]     => 34096
[2,1,1,1,1,1,1,1,1]   => 1013
[1,1,1,1,1,1,1,1,1,1] => 1

-----------------------------------------------------------------------------
Created: Sep 04, 2015 at 17:58 by Florent Hivert

-----------------------------------------------------------------------------
Last Updated: Sep 15, 2015 at 15:49 by Christian Stump