I finally finished the homework exercises.

## Homework Exercises Part 2

### Generalized Tower of Hanoi

To solve this, I first observed that for $n=1$, we need $m_1$ moves, and for $n \gt 1$, we need $A(m_1, \cdots, m_{n-1}) + m_n + A(m_1, \cdots, m_{n-1})$ or $2A(m_1, \cdots, m_{n-1}) + m_n$ moves.

This leads to the solution,

which is trivially shown by induction. The base case:

And for larger $n$, assuming $A(m_1, \cdots, m_n) = \sum_{i=1}^n m_i 2^{n-i}$,

### Zig-zag lines

A geometric problem, but very similar to the previous intersecting lines. A zig-zag is made of 3 segments, so a pair of zig-zag lines can intersect at 9 different points. The first zig-zag line defines two regions; each new zig-zag adds a new region, plus one more for each intersection point.

This gives the following recurrence equations:

Using the linearity of the recurrence equation, it is easy to see that

Here I used the linearity to compute solutions to both $ZZ_n = ZZ_{n-1} + 9(n-1)$ and $ZZ_n = ZZ_{n-1} + 1$, which are equally trivial. Then I combined the solutions into one.

I use (again) induction to confirm the solution. The base case is $ZZ_1 = ZZ_1 + 9S_0 + 0$. And for other $n$, assuming $ZZ_n = ZZ_1 + 9S_{n-1} + (n-1)$

The formula can also be written as

### Planes cutting cheese

Again, a geometric problem. This one gave me more trouble. It took me a while before finally seeing that a new plane intersection with the previous ones will be a set of intersecting lines which defines the regions the new plan will divide in two.

The number of regions formed by intersecting lines was solved in the book, and defined as $L_n = S_n + 1$

So a plane cutting $n$ existing planes will define $P_{n+1} = P_n + L_n$ new regions. This recurrence gives $P_5 = 26$ regions.

The book did not expect a closed formula for this exercise, as the necessary techniques are only covered in chapter 5.

### Josephus co-conspirator

The recurrence equation for $I(n)$ follow the structure of $J(n)$, but with different base cases:

Here I generated the first few values to get inspired. I noticed that $I(n)$ had increasing odd values for batches that were longer than for $J(n)$: $3, 6, 12, 24, \cdots$.

These numbers are from the series $3\cdot 2^m$, so using the same “intuitive” step as in the book, I tried to show that $I(3\cdot 2^m + l) = 2l + 1$ with $0 \le l \lt 3\cdot 2^m$ (the formula does not work for $I(2)$, which has to be defined separately).

By induction on $m$: the base case is $I(3) = I(3\cdot 2^0 + l) = 1$.

Assuming $I(3\cdot 2^m + l) = 2l+1$, we have

The book solution is defined in terms of $2^m+2^{m-1}+k$, which is same:

with $1 \le m$, while I have $0 \le m$.

### Repertoire method

I put the repertoire method in its own post as it was both the most difficult exercise and the one where I learned the most.