Easy Problemscountinglinearcombinatorics

Painting Fence Algorithm

Given n fence posts and k available colors, count the number of ways to paint every post so that at most two consecutive posts ever share the same color.

Do this lesson first: climbing stairs

The full breakdown and animated table for this problem are still being written. In the meantime, run the four questions on it yourself — that is the whole exercise.