1 
2 #include "comb/young-tab-rgs.h"
3 #include "comb/young-tab-rgs-descents.h"
4 // demo-include "comb/print-young-tab-rgs-aa.cc"
5 // demo-include "comb/is-shifted-young-tab-rgs.h"
6 
7 #include "comb/comb-print.h"  // print_set()
8 #include "fxtio.h"
9 #include "fxttypes.h"
10 #include "jjassert.h"
11 
12 #include "nextarg.h"
13 
14 
15 //% OEIS sequence A225616:
16 //% Tableaux of size n with major index equal to 1 mod n.
17 //% A descent in a standard Young tableau is a entry i such that i+1 lies
18 //% strictly below and weakly left of i.
19 //% The major index is the sum of all such i.
20 //% Also sequences A161125 (descent numbers), A225617 (strict inversions),
21 //%   and A225618 (weak inversions).
22 
23 // Cf. comb/young-tab-rgs-demo.cc
24 
25 //#define TIMING  // uncomment to disable printing
26 
27 
28 int
main(int argc,char ** argv)29 main(int argc, char **argv)
30 {
31     ulong n = 4;
32     NXARG(n, "Length of strings");
33     ulong m = 0;
34     NXARG(m, "Number of allowed values for digits\n"
35           "         == max height of tableaux, 0 ==> all");
36     if ( m > n )  m = n;
37     if ( m==0 )  m = n;
38 
39     young_tab_rgs Y(n, m);
40 
41     ulong ct = 0;
42     ulong sct = 0;
43 
44 
45     bool tq = 1;
46     NXARG(tq, "Whether do draw tableaux (as ASCII art)");
47 
48     ulong j = 0;
49     do
50     {
51         ++ct;
52 
53         if ( (Y.major_index() % n) == 1 )  ++sct;  // major index == 1 (mod n): A225616
54 
55 //        sct += Y.major_index();  // A000000
56 //        sct += Y.descent_number();  // A161125
57 
58 //        sct += Y.number_strict_inversions();  // A225617
59 //        sct += Y.number_weak_inversions();  // A225618
60 
61 #ifndef TIMING
62         cout << setw(4) << ct << ":  ";
63 
64         Y.print("  ");  // RGS
65 
66 //        Y.print_stats("  ");  // aux: partition
67 //        Y.print_r("  ");  // aux:  r[i] is the row (>=1) the entry i lies in
68 //        cout << setw(3) << j << " ";  // leftmost change
69 
70 //        Y.print_stats("    ");  // stats: partition of n
71 //        cout << setw(3) << Y.height();  // height
72 
73 
74         if ( tq )
75         {
76             cout << endl;
77             Y.print_aa( 1 );  // arg is offset (0 or 1)
78             ulong D[128];
79             const ulong dn = Y.descent_set( D );
80             print_set("  ", D, dn);
81             cout << endl;
82         }
83 
84 
85         cout << endl;
86 
87         jjassert( Y.OK() );
88 #endif  // TIMING
89     }
90     while ( (j=Y.next()) );
91 
92 
93 
94 #ifndef TIMING
95     cout << " ct=" << ct;
96     cout << "    sct=" << sct;
97 #else
98     cout << " ct=" << sct;
99 #endif
100     cout << endl;
101 
102     return 0;
103 }
104 // -------------------------
105 
106 /*
107  echo $(for n in $(seq 1 15); do ./bin $n ; done | g ct=) | sed 's/ ct=/, /g;'
108 ct=0, 1, 1, 2, 5, 12, 33, 94, 290, 949, 3245, 11666, 43731, 170748, 689957
109 */
110 
111 
112 /// Emacs:
113 /// Local Variables:
114 /// MyRelDir: "demo/seq"
115 /// makefile-dir: "../../"
116 /// make-target: "1demo DSRC=demo/seq/A225616-demo.cc"
117 /// make-target2: "1demo DSRC=demo/seq/A225616-demo.cc DEMOFLAGS=-DTIMING"
118 /// End:
119 
120