Interesting problems tend to follow a pattern of being very easy to state, and hard to solve. I am sharing one as an example. Do try to solve it before reading through the solution. Enjoy!
Problem
In how many ways can you cover a 3×n grid with 2×1 sized dominoes?
Solution
Approach
We will write the number of solutions recursively, and deduce the general formula based on this.
Recursions
After adding dominoes we get grids that might not be 3×n, so let us define these three values:
An : The number of coverings of a 3×n grid with an extra cell in the n+1 th column.
Bn : The number of coverings of a 3×n grid with two extra adjacent cells in the n+1 th column.
Cn : The number of coverings of a 3×(n+1) grid.
With these in mind, we get three key recursions:
⎩⎨⎧An=Bn=Cn=Bn−1Cn−1+An−1Bn−1+Cn−2+An
Using An=Bn−1 to get rid of all the An terms we get the system of equations
{Bn=Cn=Cn−1+Bn−22Bn−1+Cn−2
In order to get similar recursions, we can define Cn′=2Cn to get the system of equations.
{Bn=Cn′=2Cn−1′+Bn−22Bn−1+Cn−2′
Due to Bn and Cn′ ‘s similarity, we can work out this system in terms of their average value and difference, by setting