Sandbox

https://oeis.org/A005251

test
$${2 \choose M}$$

$$ \left( \! \tbinom{n}{k} ! \right) $$

$$ \begin {Bmatrix} x & y \\ z & v \end {Bmatrix} $$

avoiding 00, 11, 111
Here is a rewriting of above work using automaton and generating functions. The associated grammars need to be unambiguous; if not, because of the copies, the numbers obtained will be higher than the right ones.

By the second diagram, one may write

$$A = x + xC + xD$$ where :

$$A = a_1x + a_2x^2 + a_3x^3 + ... $$ is the generating function (or the string index) for words that ends exactly in 0. The same for B, C, D.

Similarly, the other three equations are:

$$B = x^3 + xB + x^3C + x^3D $$

$$C = x + xA + xB$$

$$D = x^4 + x^4A + x^4B + xD$$

$$x^3$$ covers the bit string 000; $$x^4$$ covers the bit string 1111;

This system easily solves to the same solution as the first diagram :

here (for example), $$x + {x^3 \over 1-x } $$encodes the set { 0, 000, 0000, 00000, ....}

the two equations are

$$ A+B = {x-x^2+x^3 \over 1-x } ( C + D + 1 ) $$and

$$ C+D = {x-x^2+x^4 \over 1-x } ( A + B + 1 )$$ that easily solves to $$ W=A+B+C+D= {2x - 2x^2 - x^3 + 4x^4 -x^5 -2x^6 + 2x^7 \over 1 - 2x + 2x^3 - 2x^4 + x^6 - x^7} $$

$$= 2+2x +3x^2 +6x^3 +11x^4 +18x^5+30x^6 +50x^7 +85x^8 +143x^9+ 241x^{10} + ...$$

The denominator encodes the required recurrence.

avoiding 101
$$\begin{cases} A = yA+yC+1\\ B= xA+1 \\ C = yB+yD+1\\ D = xB+xD+1 \end{cases}$$

$$A+B+C+D = y(A+B+C+D) + x(A+B+D) + 4 $$

$$A+B+D = (yA + xB+ yC + xD) + xA + 3 $$

$$yA + xB + yC + xD = $$

$$y(yA+yC+1) + x(xA+1 ) + y(yB+yD+1) + x (xB+xD + 1) = $$

$$(y^2+x^2)A + (y^2+x^2)B + y^2C + (y^2 + x^2)D + (x^3 + x^2y + x y^2 + y^3 )  = $$

$$ y^2(A+B+C+D) + x^2 (A+B+D) + 2x+2y) = $$

$$A = yA+yC + 1 = y(yA+yC + 1) + y( yB+yD+ 1) + 1 = $$

$$ y^2(A+B+C+D) + 1+2y $$

$$\begin{cases} E = yE + xF + 4 \\ F= y^2E+x^2F + xA + 3 + 2x + 2y \\ A = y^2E + 1 + 2y \end{cases}$$

$$\begin{cases} E = yE + xF + 4 \\ F= y^2E+x^2F +xy^2E + x(1 + 2y) + 3 + 2x + 2y \end{cases}$$

$$F(1-x^2) = (y^2+xy^2) E + 3 + 3x + 2y + 2xy $$

$$E = yE + \frac {x(y^2+xy^2)E + x.polynomial} {(1-x^2) } + 4   $$

$$(1-x^2)E = (1-x^2)yE + x(y^2+xy^2)E + x.polynomial+ (1-x^2)4  $$

using x, y
$$\begin{cases} A = yA+yC+y^2\\ B= xA+xy \\ C = yB+yD+xy \\ D = xB+xD+x^2 \end{cases}$$

$$A+B+C+D = y(A+B+C+D) + x(A+B+D) + (x+y)^2$$

$$A+B+D = (yA + xB+ yC + xD) + xA + (y^2 + xy + x^2)$$

$$yA + xB + yC + xD = $$

$$y(yA+yC+y^2) + x(xA+xy ) + y(yB+yD+xy ) + x (xB+xD+x^2) = $$

$$(y^2+x^2)A + (y^2+x^2)B + y^2C + (y^2 + x^2)D + (x^3 + x^2y + x y^2 + y^3 )  = $$

$$ y^2(A+B+C+D) + x^2 (A+B+D) + (x^3 + x^2y + x y^2 + y^3 ) = $$

$$A = yA+yC+y^2 = y(yA+yC+y^2) + y( yB+yD+xy) + y^2 = $$

$$ y^2(A+B+C+D) + (y^3+xy^2+y^2)$$

$$\begin{cases} E = yE + xF + (x+y)^2 \\ F= y^2E+x^2F +xA + (y^2 + xy + x^2) + (x^3 + x^2y + x y^2 + y^3 ) \\ A = y^2E + (y^3+xy^2+y^2) \end{cases}$$

$$\begin{cases} E = yE + xF + (x+y)^2 \\ F= y^2E+x^2F +xy^2E + x(y^3+xy^2+y^2) + (y^2 + xy + x^2) + (x^3 + x^2y + x y^2 + y^3 ) \end{cases}$$

$$F(1-x^2) = (y^2+xy^2)E + polynomial$$

$$E = yE + \frac {x(y^2+xy^2)E + x.polynomial} {(1-x^2) }+ (x+y)^2   $$

$$(1-x^2)E = (1-x^2)yE + x(y^2+xy^2)E + x.polynomial+ (1-x^2)(x+y)^2   $$

$$\frac {x^3y^2+x^2y^3-x^3y+x^2y^2+xy^3+x^3+x^2y+xy^2+x^2+2xy+y^2}{-x^2y^2+x^2y-xy^2-x^2-y+1} $$

(checked in Maple) 3329*x^14+1897*x^13+1081*x^12+616*x^11+351*x^10+200*x^9+114*x^8+65*x^7+37*x^6+21*x^5+12*x^4+7*x^3+4*x^2

using only x
$$\begin{cases} A = xA+xC+x^2\\ B= xA+xx  \\ C = xB+xD+xx \\ D = xB+xD+x^2 \end{cases}$$

$$A+B+C+D = x(A+B+C+D) + x(A+B+D) + 4x^2$$

$$A+B+D = x(A + B+ C+ D) + xA + 3x^2 $$

$$A+B+C+D = (x+x^2)(A+B+C+D) + x^2A + 4x^2 + 3x^3$$

$$A = xA+xC+x^2 = x(xA+xC+x^2) + x( xB+xD+xx) + x^2 = $$

$$ x^2(A+B+C+D) + (x^3+xx^2+x^2)$$

$$\begin{cases} E = (x+x^2)E + x^2A + 4x^2 + 3x^3 \\ A = x^2E + 2x^3+x^2 \end{cases}$$

$$E = (x + x^2 + x^4)E  + 2x^5 + x^4 + 3x^3 + 4x^2$$

$$e.g.f = \frac {2x^5 + x^4 + 3x^3 + 4x^2}{1-x-x^2-x^4} = 4x^2+ 7x^3+12x^4+21x^5+37x^6+ 65x^7+...$$

using only x, start from 1
$$\begin{cases} A = xA+xC+ 1\\ B= xA  \\ C = xB+xD \\ D = xB+xD \end{cases}$$

$$A+B+C+D = x(A+B+C+D) + x(A+B+D) + 1$$

$$A+B+D = x(A + B+ C+ D) + xA + 1 $$

$$A+B+C+D = (x+x^2)(A+B+C+D) + x^2A + 1 + x$$

$$A = xA + xC + 1 = x(xA+xC+1) + x( xB+xD) + 1= $$

$$ x^2(A+B+C+D) + x+1 $$

$$\begin{cases} E = (x+x^2)E + x^2A + x + 1 \\ A = x^2E + x+1 \end{cases}$$

$$E = (x + x^2 + x^4) E  + x^3 + x^2 + x + 1$$

$$\frac {1 + x + x^2 + x^3}{1-x-x^2-x^4} = 1+2x+4x^2+7x^3+12x^4+21x^5+37x^6+65x^7+...$$

using 1, 0
$$\begin{cases} A = A0+C0+00\\ B= A1+01 \\ C = B0+D0+10 \\ D = B1+D1+11 \end{cases}$$

$$A+B+C+D = (A+B+C+D)0 + (A+B+D)1 + (0+1)^2$$

$$A+B+D = (A0 + B1 + C0 + D1) + A1 + (00 + 01 + 11)$$

$$A0 + B1 + C0 + D1 = $$

$$(A0+C0+00)0 + (A1+01)1 + (B0+D0+10)0 + (B1+D1+11)1 = $$

$$A(00+11) + B(00+11) + C00 + D(00+11) + (000 + 011 + 110 + 111 )  = $$

$$ (A+B+C+D)00 + (A+B+D)11 + (000 + 011 + 110 + 111 )  = $$

$$A = A0+C0+00 = (A0+C0+00)0 + (B0+D0+10)0 + 00 = $$

$$ (A+B+C+D)00 + (000 + 100 + 00)$$

$$\begin{cases} E = E0 +F1 + (0+1)^2\\ F = E00 + F11 + A1 + (00 + 01 + 11 + 000 + 011 + 110 + 111 ) \\ A = E00 + (000 + 100 + 00) \end{cases}$$

$$\begin{cases} E = E0 +F1 + (0+1)^2\\ F = E00 + F11 + E001 + (000 + 100 + 00)1 + (00 + 01 + 11 + 000 + 011 + 110 + 111 ) \end{cases}$$

$$F - F11 = E(00 +001) + (0001 + 1001 + 001 + 00 + 01 + 11 + 000 + 011 + 110 + 111 ) $$

$$\begin{cases} E = E0 + F1 + (0+1)^2\\ E11 = E011 +F111 + (0+1)^211\\ F1 - F111 = E(001 +0011) + (00011 + 10011 + 0011 + 001 + 011 + 111 + 0001 + 0111 + 1101 + 1111 ) \end{cases}$$

$$E-E0 -E11 + E011 - E001-E0011 = $$ $$ (0+1)^2 - (0+1)^211 + (00011 + 10011 + 0011 + 001 + 011 + 111 + 0001 + 0111 + 1101 + 1111 ) $$ $$ = (0+1)^2 - 1011 + (00011 + 10011 + 001 + 011 + 111 + 0001 + 1101) $$

$$\frac {x^3y^2+x^2y^3-x^3y+x^2y^2+xy^3+x^3+x^2y+xy^2+x^2+2xy+y^2}{-x^2y^2+x^2y-xy^2-x^2-y+1} $$

(checked in Maple) 3329*x^14+1897*x^13+1081*x^12+616*x^11+351*x^10+200*x^9+114*x^8+65*x^7+37*x^6+21*x^5+12*x^4+7*x^3+4*x^2

probabilities bayes
Here how Bayes may join the lulu solution a)

\frac{1}{ 1\over 13} = \frac {P(AS\ in\ hand\ |\ success) } {P(success\ |\  AS\ in\ hand)}  = \frac {P(AS\ in\ hand)}{P(success)} = \frac {x} {1\over 52}

and we get the first 1/4

b) reusing it,

\frac{x}{ 12\over 13} = \frac {P(AS\ in\ hand\ |\ failure) } {P(failure\ |\  AS\ in\ hand)}  = \frac {P(AS\ in\ hand)}{P(failure)} = \frac {1\over 4} {51\over 52}

we obtain the 1 - 12/51

c) in fact we are interested in

\frac{x} {  ( {12 \over 13} ) ^{10} } = \frac {P(AS\ in\ hand\ |\ 10\ failures) } {P(10\ failures\ |\  AS\ in\ hand)}  = \frac {P(AS\ in\ hand)}{P(10\ failures)} = \frac {1\over 4} {y}

where

$$ y = P(10\ failures) = P(10\ failures \cap AS\ in\ hand) + P(10\ failures \cap AS\ not\ in\ hand) $$

hence the result

x = \frac{P(10\ failures \cap AS\ in\ hand)} {P(10\ failures)}

In fact

a) Bayes is not needed b) Bayes is not needed c) Bayes in not needed.

avoiding three consecutives
$$\begin{cases} AA = BAa \\ BB= ABb \\ AB = AAb+ BAb\\ BA = BBa + ABa \end{cases}$$

$$AA + BB +AB+BA= BAa + ABb + AAb+ BAb +BBa + ABa = BBaa + ABaa + AAbb+ BAbb $$

$$A+B+D = (yA + xB+ yC + xD) + xA + 3 $$

$$yA + xB + yC + xD = $$

$$y(yA+yC+1) + x(xA+1 ) + y(yB+yD+1) + x (xB+xD + 1) = $$

$$(y^2+x^2)A + (y^2+x^2)B + y^2C + (y^2 + x^2)D + (x^3 + x^2y + x y^2 + y^3 )  = $$

$$ y^2(A+B+C+D) + x^2 (A+B+D) + 2x+2y) = $$

$$A = yA+yC + 1 = y(yA+yC + 1) + y( yB+yD+ 1) + 1 = $$

$$ y^2(A+B+C+D) + 1+2y $$

$$\begin{cases} E = yE + xF + 4 \\ F= y^2E+x^2F + xA + 3 + 2x + 2y \\ A = y^2E + 1 + 2y \end{cases}$$

$$\begin{cases} E = yE + xF + 4 \\ F= y^2E+x^2F +xy^2E + x(1 + 2y) + 3 + 2x + 2y \end{cases}$$

$$F(1-x^2) = (y^2+xy^2) E + 3 + 3x + 2y + 2xy $$

$$E = yE + \frac {x(y^2+xy^2)E + x.polynomial} {(1-x^2) } + 4   $$

$$(1-x^2)E = (1-x^2)yE + x(y^2+xy^2)E + x.polynomial+ (1-x^2)4  $$

3157084 Pólya-Burnside Method of Enumeration with Necklace

a problem in math stackexchange
1. The cycle index polynomial of $$D_6$$ is $$\frac{1}{12}[x_1^6+3x_1^2x_2^2+4x_2^3+2x_3^2+2x_6]$$. So, the number of necklaces is the coefficient of $$a^3b^3$$ in the expansion of

$$\frac{1}{12}[(a+b)^6+3(a+b)^2(a^2+b^2)^2+4(a^2+b^2)^3+2(a^3+b^3)^2+(a^6+b^6)],$$

which is equal to $$\displaystyle \frac{1}{12}\left[\binom{6}{3}+3\binom{2}{1}\binom{2}{1}+2\binom{2}{1}\right]=3$$.

2. The cycle index polynomial of $$D_8$$ is $$\frac{1}{16}[x_1^8+4x_1^2x_2^3+5x_2^4+2x_4^2+4x_8]$$. So, the number of necklaces is the coefficient of $$a^4b^3c$$ in the expansion of

$$\frac{1}{16}\left[(a+b+c)^8+4(a+b+c)^2(a^2+b^2+c^2)^3+5(a^2+b^2+c^2)^4+2(a^4+b^4+c^4)^2+4(a^8+b^8+c^8)\right]$$

which is equal to $$\displaystyle \frac{1}{16}\left[\binom{8}{4}\binom{4}{3}+4\binom{2}{1}\binom{3}{2}\right]=19$$.