Generating function from a set of binary strings

334 Views Asked by At

So this question is in my textbook and there's no solution, so I'm seeing if I can get a confirmation?

Q: Let $S$ be the set of all binary strings of length 4, where for each string $a\in S$, the weight $w(a)$ is defined to be the number of times 11 appears in the string. So for example, $w(1101) = 1, w(1111) = 3$

So i know that there is a total of $2^4=16$ configurations. I listed them all out and determined the weight of each of them.

I concluded that 8 configurations had weight 0, 5 had weight 1, 2 had weight 2, and 1 had weight 3.

So would my generating function look like this:

$8 +5x +2x^2 + x^3$ ?

Is there another way to find this? or was listing it out the only option in this case?

Thanks