posts posts in a row, and there are colors different paints. Each post gets exactly one paint, but three or more neighbouring posts in a row must not share a colour.
In how many ways can the fence be painted?posts=3, colors=2 → 6
Of the 2³ = 8 colorings, only the two where all three posts share a colour are ruled out.
posts=4, colors=1 → 0
With a single colour, three neighbouring posts are bound to match.
posts=2, colors=5 → 25
Two posts can be painted freely: 5 · 5 = 25.
posts=3, colors=2
6
Run checks the first 3 tests in your browser. Submit checks all 37 tests on the server, hidden ones included.