Question to generating function

44 Views Asked by At

This is the question/riddle:

Five people who wear a red hat spread a gossip. In the first hour every one of them tells the gossip to one other person not yet wearing a red hat. The new insiders than immediately put on a red hat. This trend repeats itself with the following rule: Every person tells the gossip to one other person in the first hour he heard the gossip, and to nine other persons in the following hours. Nobody removes his hat, how many persons wear the red hat (heard the gossip) after n-hours? Hint: use generating functions

My question is, how would I turn a question like this into a generating functions? This is my attempt: $(1+x)(1+x)(1+x)(1+x)(1+x)+(1+x+x^2+x^3+x^4+x^5+x^6+x^7+x^8+x^9) \cdot n$

Five $(1 + x)$ representing the first five persons plus the nine new one's multiplied by $n$.

But I doubt this is correct.

What is the good generating function to solve this question, and how to get it?