PRiMAL
Explore with PRogramming, Math, and ALgorithms...
(under construction)


The intimidated chickens
Consider $n$ chickens sitting in a row. Each chicken is oriented to look either to the left or to the right. Chicken $i$ is intimidated iff chickens $i-1$ and $i+1$ are both looking at it. A good orientation of the chickens is one in which no chicken is intimidated. In the following figure, the second chicken is intimidated.

How many good orientations are there? This is a counting problem, so a natural starting point is combinatorics. However, one could also experiment with code to generate good orientations and obtain a mathematical hint (for instance, by generating all orientations for small $n$ and dropping the bad ones). One interesting aspect of this setting is that the number of good orientations is only polynomial in $n$ (and thus very far from the exponentially large total of $2^n$ orientations).

Once this is known, it becomes clear that an algorithm to generate all good permutations is not hard to conceive. We can ask to design such an algorithm with optimal running time, thus moving from experimental (inefficient) code, to math, to optimal algorithm.

For further endeavors, the number of good orientations of $n$ chickens, call it $g_n$, can be described by a non-trivial recurrence involving $g_{n-1}$, $g_{n-2}$, $g_{n-3}$, and $g_{n-4}$. Using wolframalpha, we can explore this recurrence and its closed-form solution, which may reveal an expression different from the one obtained initially. This in turn provides an opportunity to explore mathematical proofs and discover an identity. In addition, the sequence $g_n$ can be related to many combinatorial problems in the literature. By discovering candidate problems using oeis, we will gain a deeper understanding of the combinatorial nature of these problems and establish how/why they are related.