How many sequences :$a_1,a_2,...,a_8$ How many sequences $a_1,a_2,...,a_8$ from zeros and ones ,and such  that :
$$a_1\cdot a_2+a_2 \cdot a_3+\cdots + a_7\cdot a_8=5$$ 
 A: Hint: note that this means that exactly $5$ of the pairs are of the form $1\cdot 1$
A: if any of a3,a4,a5,or a6 are zero, then no other element can be zero, since they would make two terms 0. so these inner ones give rise to 4 assignments. however, a2 and a7 are such that they are present with terms a1 and a8 respectively, and these appear only once. so if a2 is 0, a1 may or may not be zero, and similarly, if a7 is 0, a8 may or may not be 0, so these give rise to four more assigments. finally, we have one assignment with a1 0 and a8 0, and the rest are all 1's, for a total of 9 assignments.
A: I will use Haskell to brute-force this. Here's a GHCi session:
Prelude> let xs = [ (a1,a2,a3,a4,a5,a6,a7,a8) | a1 <- [0,1], a2 <- [0,1],
                                                a3 <- [0,1], a4 <- [0,1],
                                                a5 <- [0,1], a6 <- [0,1],
                                                a7 <- [0,1], a8 <- [0,1], 
                                                a1*a2 + a2*a3 + a3*a4 + a4*a5 + a5*a6 + a6*a7 + a7*a8 == 5]
Prelude> xs
[(0,0,1,1,1,1,1,1),(0,1,1,1,1,1,1,0),(1,0,1,1,1,1,1,1),(1,1,0,1,1,1,1,1),(1,1,1,0,1,1,1,1),(1,1,1,1,0,1,1,1),(1,1,1,1,1,0,1,1),(1,1,1,1,1,1,0,0),(1,1,1,1,1,1,0,1)]
Prelude> length xs
9

So, the answer would be: there are $9$ sequences.
