Processing math: 58%
The intimidated chickens problem
(Saad Mneimneh and Alexey Nikolaev)

The 2017 Raytheon Mathcounts National Competition contained the following question: In a barn, 100 chicks sit peacefully in a cricle. Suddenly, each chick randomly pecks the chick immediately to its left or right. What is the expected number of unpecked chickens? (the answer is 100/4=25) This question inspired the intimidated chickens problem:

Consider n chickens sitting in a row. Each chicken is oriented to look either to the left or to the right. We say that chicken i is intimidated iff chickens i1 and i+1 are both looking at it. A good orientation of the chickens is one in which no chicken is intimidated (the second chicken below is intimidated).




This interesting formulation is related to a famous sequence known as the quarter-squares: an=n/2n/2=n2/4, for n0: 0,0,1,2,4,6,9,12,16,20,25,30,36,42,49,56,64,72,81,90,100,110,121,132,144, It turns out that the number of good orientations is gn=an+2,n0. To derive this result, think of a binary word b1b2bn, where 0 represents left and 1 represents right. As such, we must have bibi+2. So each of the sequences b1,b3, and b2,b4, must be non-decreasing, i.e. must switch from 0 to 1 at most once. Therefore, there are n/2+1=(n+2)/2 and n/2+1=(n+2)/2 possible sequences, respectively. By the product rule, this gives an+2.

Another interesting way to derive this result is to first establish the recurrence gn=2gn12gn3+gn4, by emphasizing the start of the binary pattern: gn=0_gn1+[1_gn1100_gn3(110_gn31100_gn4)] The characteristic equation of the above recurrence is x42x3+2x1=0, which is the same as (x1)3(x+1)=0 with solutions p=q=r=1 and s=1, resulting in gn=c1(1)n+c2n(1)n+c3n2(1)n+c4(1)n. Given g0=1, g1=2, g2=4, and g3=6, we get gn=n+[7+2n2+(1)n]/8, which can be shown to be an+2 (e.g. by induction).

For large n, if each chicken is randomly oriented to the left or to the right with equal probability, then the probability of a good orientation is approximately given by the following cool expression (this is exact when n is even, and overshoots by 1/2n+2 when n is odd): (n+2)22n+2 The circular version of this problem is not very interesting, with the number of good orientations c0=1, and for n>0, cn=2 if n is odd (all chickens face the same direction), and cn=4 if n is even (chickens with the same parity, i.e. either even numbered or odd numbered, face the same direction). However, the expected number of intimidated chickens does not change dramatically, n/4 in the circular case compared to (n2)/4 in the linear case. It can be shown that cn=gn4gn3+3gn4, so an4an3+3an4 is either 2 or 4, which can be verified in the above sequence.

Here is another related problem: Given the set of integers {1,2,,n}, select k integers in such a way that no two of them have a difference of exactly 2. Let An,k be the number of ways we can do that. It is not hard to establish the following recurrence (based on how we select in the subset {1,2}): An,k=An1,k+An3,k1+An4,k2 which can be used to compute An,k for several values of n and k. We can then observe that A2n,n is also equal to an+2. Therefore, A2n,n=gn=k0An2,k2n2k(1)k=2nk0An2,k(14)k=an+2 where n/2 can be used as a practical upprer bound for k (n2k0). The second equality is given by the principle of inclusion and exclusion, where we subtract from 2n (when k=0) the number of orientations with at least one intimidated chicken: 2n2k counts the number of orientations that intimidate a given fixed set of k chickens, and An2,k counts the number of such sets (two intimidated chickens cannot be at a distance of exactly 2, and the first and last chickens cannot be intimidated).

In fact, we can solve for An,k and show that A2n,n=an+2. A valid selection of k integers in {1,2,,n} defines runs of consecutive integers. Observe that every run must contain either 1 or 2 integers. If the total number of runs is r, then kr of these must have size 2, and so there are Crkr ways of choosing those runs. The remaining nk integers (which were not selelected) form r+1 gaps between runs, the lengths of which can be described by the following equation: l0+l1++lr1+lr=nk where l1,,lr12, and l0,lr0. The number of non-negative integer solutions for this equation is Cnkr+2r, given by a standard counting method as long as 0rnk+2. Therefore, An,k=0rnk+2CrkrCnkr+2r Observe that the practical lower and upper bounds for r in An,k are k/2 (rkr) and min (k-r\geq 0 and n-k-r+2\geq r), respectively. Therefore, to compute A_{2n,n}=\sum_r C_{n-r}^rC_r^{n-r+2}, we may use: A_{2n,n}=\sum_{r=\lceil n/2\rceil}^{\lfloor n/2\rfloor+1} C_{n-r}^rC_r^{n-r+2} When n is odd, the sum contains one term. When n is even, it contains two terms. By expanding the binomial coefficients in every term, A_{2n,n} simplifies to (n+1)(n+3)/4 when n is odd, and (n+2)^2/4 when n is even, which is \lfloor (n+2)^2/4\rfloor=a_{n+2} for every n.

Given the solution for A_{n,k}, we can now write: g_n=2^n\sum_{k=0}^{\lfloor n/2\rfloor} \sum_{r=\lceil k/2\rceil}^{\min\{k,\lfloor (n-k)/2\rfloor\}} C_{k-r}^rC_r^{n-k-r}\Big(-\frac{1}{4}\Big)^k The bounds can be relaxed; for instance, when r is bounded, we can make k\geq 0, and similarly, when k is bounded, we can make r\geq 0 (all values of r are safe since anomalies arise when n-k-r\leq -1 and 0\leq k-r\leq r, which would make k>n/2). The following figure illustrates three areas for (k,r): green is needed, red must be avoided, and white makes no difference (green and red include their boundaries).



An interesting observation is that \sum_{k\geq 0}A_{n,k} satisfies a recurrence similar to that of A_{n,k}. In particular, it is not hard to see that \sum_{k\geq 0}A_{n,k}=\sum_{k\geq 0}A_{n-1,k}+\sum_{k\geq 0}A_{n-3,k}+\sum_{k\geq 0}A_{n-4,k}. Another known sequence with this recurrence is \alpha_n for n\geq 0: 1, 1, 1, 2, 4, 6, 9, 15, 25, 40, 64, 104, \ldots which makes \sum_{k\geq 0}A_{n,k}=\alpha_{n+2} related to Fibonacci numbers: \alpha_n-\alpha_{n-4}=\alpha_{n-1}+\alpha_{n-3}=F_n, and when n is even, \alpha_{n}=F^2_{(n+2)/2}, and when n is odd, \alpha_{n}=F_{(n+1)/2}\cdot F_{(n+3)/2}. Therefore, \sum_{k\geq 0}A_{n-2,k}=\alpha_{n}=\sum_{k=0}^{\lfloor n/2\rfloor }\sum_{r=\lceil k/2\rceil}^ {\min\{k,\lfloor(n-k)/2\rfloor\}}C_{k-r}^rC_r^{n-k+r}=\left\{ \begin{array}{ll} F^2_{(n+2)/2} & n \textrm{ is even}\\ F_{(n+1)/2}\cdot F_{(n+3)/2} & n \textrm{ is odd} \end{array} \right. where the bounds in the summations can also be relaxed as described above. The number \alpha_{n} counts the subsets of \{1,2,\ldots,n\} in which all the chickens can be intimidated simultaneously. This is beautiful when compared to g_n: g_n=2^n\sum_{k=0}^{\lfloor n/2\rfloor} \sum_{r=\lceil k/2\rceil}^{\min\{k,\lfloor (n-k)/2\rfloor\}} C_{k-r}^rC_r^{n-k-r}\Big(-\frac{1}{4}\Big)^k= \left\{\begin{array}{ll} [(n+2)/2]^2 & n \textrm{ is even}\\ (n+1)/2\cdot (n+3)/2 & n \textrm{ is odd} \end{array} \right. If we now define B_{n,k} as the number of orientations in which exactly k out of n chickens are intimidated, then B_{n,0}=g_n, \sum_{k\geq 0}B_{n,k}=2^n, and \sum_{k>\lfloor n/2\rfloor}B_{n,k}=0. But what is B_{n,k} for any given n and k? B_{n,1} (0,0,0,2,6,16,32,60,100,160,240,\ldots) is related to the number of non-palindromic reversible strings with 4 black and n-5 white beads. B_{n,2} (0,0,0,0,1,4,16,44,110,236,472,\ldots) is related to the number of bracelets with 1 blue, 6 identical red, and n identical black beads. B_{n,2} and B_{n,4} (0,0,0,0,0,0,0,0,1,6,36,146,511,1512,\ldots) are also related to parrafin numbers (page 1925) l(9,n) and l(13,n), respectively.