
#include "comb/paren-gray.h"

#include "demo/nextarg.h"
#include "fxtio.h"

//% Parentheses strings in minimal-change order (Xiang, Ushijima)

//#define TIMING // uncomment to disable printing

int
main(int argc, char **argv)
{
    ulong n = 5;
    NXARG(n, "Number of parentheses pairs");

    paren_gray P(n);

    ulong ct = 0;
    do
    {
        ++ct;
#ifndef TIMING
        cout << setw(4) << ct << ":    ";
        cout << P.string();
        cout << "    ";
        for (ulong k=0; k<2*n; ++k)  cout << (P.string()[k]=='(' ? '1' : '.' );
        cout << endl;
#endif  // TIMING
    }
    while ( P.next() );
    cout << " ct = " << ct << endl;

    return 0;
}
// -------------------------

/*

%  time ./bin 18
arg 1: 18 == n  [Number of parentheses pairs]  default=5
 ct = 477638700
./bin 18  5.84s user 0.01s system 99% cpu 5.862 total
 ==> 477638700/5.84 == 81,787,448 per second

*/

/// Emacs:
/// Local Variables:
/// MyRelDir: "demo/comb"
/// makefile-dir: "../../"
/// make-target: "1demo DSRC=demo/comb/paren-gray-demo.cc"
/// make-target2: "1demo DSRC=demo/comb/paren-gray-demo.cc DEMOFLAGS=-DTIMING"
/// End:
