How many ways to paint a board with 2 colors..

311 Views Asked by At

You got a fence, you need to paint the boards with black and white, but can not have 3 or more boards same color in a row. how many ways do you have?

1

There are 1 best solutions below

3
On

As user bof pointed out in a comment, the OP is most likely looking for the number of binary strings avoiding the substrings $000$ and $111$. If so, then the answer can be found in sequence A128588 of the OEIS, where $a(n)$ is the number of binary strings of length $n-1$ avoiding the substrings $000$ and $111$. The sequence starts "$1, 2, 4, 6, 10, 16, 26, 42,\ldots$," so, for example, if there are $3$ boards, there are $a(4)=6$ ways of painting the board: $001,010,011,100,101,110$.