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

-----------------------------------------------------------------------------
Collection: Binary words

-----------------------------------------------------------------------------
Description: The number of permutations whose descent word is the given binary word.

This is the sizes of the preimages of the map [[Mp00109]].

-----------------------------------------------------------------------------
References: 

-----------------------------------------------------------------------------
Code:
from collections import defaultdict

def word(pi):
    w = [0]*(len(pi)-1)
    for i in pi.descents():
        w[i] = 1
    return Words([0,1])(w)

@cached_function
def preimages(n):
    D = defaultdict(int)
    for pi in Permutations(n):
        D[word(pi)] += 1
    return D

def statistic(word):
    return preimages(len(word)+Integer(1))[word]

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

0       => 1
1       => 1
00      => 1
01      => 2
10      => 2
11      => 1
000     => 1
001     => 3
010     => 5
011     => 3
100     => 3
101     => 5
110     => 3
111     => 1
0000    => 1
0001    => 4
0010    => 9
0011    => 6
0100    => 9
0101    => 16
0110    => 11
0111    => 4
1000    => 4
1001    => 11
1010    => 16
1011    => 9
1100    => 6
1101    => 9
1110    => 4
1111    => 1
00000   => 1
00001   => 5
00010   => 14
00011   => 10
00100   => 19
00101   => 35
00110   => 26
00111   => 10
01000   => 14
01001   => 40
01010   => 61
01011   => 35
01100   => 26
01101   => 40
01110   => 19
01111   => 5
10000   => 5
10001   => 19
10010   => 40
10011   => 26
10100   => 35
10101   => 61
10110   => 40
10111   => 14
11000   => 10
11001   => 26
11010   => 35
11011   => 19
11100   => 10
11101   => 14
11110   => 5
11111   => 1
000000  => 1
000001  => 6
000010  => 20
000011  => 15
000100  => 34
000101  => 64
000110  => 50
000111  => 20
001000  => 34
001001  => 99
001010  => 155
001011  => 90
001100  => 71
001101  => 111
001110  => 55
001111  => 15
010000  => 20
010001  => 78
010010  => 169
010011  => 111
010100  => 155
010101  => 272
010110  => 181
010111  => 64
011000  => 50
011001  => 132
011010  => 181
011011  => 99
011100  => 55
011101  => 78
011110  => 29
011111  => 6
100000  => 6
100001  => 29
100010  => 78
100011  => 55
100100  => 99
100101  => 181
100110  => 132
100111  => 50
101000  => 64
101001  => 181
101010  => 272
101011  => 155
101100  => 111
101101  => 169
101110  => 78
101111  => 20
110000  => 15
110001  => 55
110010  => 111
110011  => 71
110100  => 90
110101  => 155
110110  => 99
110111  => 34
111000  => 20
111001  => 50
111010  => 64
111011  => 34
111100  => 15
111101  => 20
111110  => 6
111111  => 1
0000000 => 1
0000001 => 7
0000010 => 27
0000011 => 21
0000100 => 55
0000101 => 105
0000110 => 85
0000111 => 35
0001000 => 69
0001001 => 203
0001010 => 323
0001011 => 189
0001100 => 155
0001101 => 245
0001110 => 125
0001111 => 35
0010000 => 55
0010001 => 217
0010010 => 477
0010011 => 315
0010100 => 449
0010101 => 791
0010110 => 531
0010111 => 189
0011000 => 155
0011001 => 413
0011010 => 573
0011011 => 315
0011100 => 181
0011101 => 259
0011110 => 99
0011111 => 21
0100000 => 27
0100001 => 133
0100010 => 365
0100011 => 259
0100100 => 477
0100101 => 875
0100110 => 643
0100111 => 245
0101000 => 323
0101001 => 917
0101010 => 1385
0101011 => 791
0101100 => 573
0101101 => 875
0101110 => 407
0101111 => 105
0110000 => 85
0110001 => 315
0110010 => 643
0110011 => 413
0110100 => 531
0110101 => 917
0110110 => 589
0110111 => 203
0111000 => 125
0111001 => 315
0111010 => 407
0111011 => 217
0111100 => 99
0111101 => 133
0111110 => 41
0111111 => 7
1000000 => 7
1000001 => 41
1000010 => 133
1000011 => 99
1000100 => 217
1000101 => 407
1000110 => 315
1000111 => 125
1001000 => 203
1001001 => 589
1001010 => 917
1001011 => 531
1001100 => 413
1001101 => 643
1001110 => 315
1001111 => 85
1010000 => 105
1010001 => 407
1010010 => 875
1010011 => 573
1010100 => 791
1010101 => 1385
1010110 => 917
1010111 => 323
1011000 => 245
1011001 => 643
1011010 => 875
1011011 => 477
1011100 => 259
1011101 => 365
1011110 => 133
1011111 => 27
1100000 => 21
1100001 => 99
1100010 => 259
1100011 => 181
1100100 => 315
1100101 => 573
1100110 => 413
1100111 => 155
1101000 => 189
1101001 => 531
1101010 => 791
1101011 => 449
1101100 => 315
1101101 => 477
1101110 => 217
1101111 => 55
1110000 => 35
1110001 => 125
1110010 => 245
1110011 => 155
1110100 => 189
1110101 => 323
1110110 => 203
1110111 => 69
1111000 => 35
1111001 => 85
1111010 => 105
1111011 => 55
1111100 => 21
1111101 => 27
1111110 => 7
1111111 => 1

-----------------------------------------------------------------------------
Created: Jun 08, 2016 at 13:19 by Christian Stump

-----------------------------------------------------------------------------
Last Updated: Jun 08, 2016 at 13:19 by Christian Stump