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$$

-
Is this homework ? what did you try ? – Belgi Sep 19 '12 at 12:04
You can solve the problem by analyzing how many zeros there are in the sequence and in each case which are the possible cases. – digital-Ink Sep 19 '12 at 12:17

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.

-
Hey, you missed a5*a6!!! These sequences listed all give 6. – Berci Sep 19 '12 at 12:34
@BerciPecsi: You're totally right. I noticed the error and fixed it before I saw your comment. – Rod Carvalho Sep 19 '12 at 12:37

Hint: note that this means that exactly $5$ of the pairs are of the form $1\cdot 1$

-
Would the downvoter care to explain what is wrong with my hint ? – Belgi Sep 19 '12 at 13:54

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.

-