Find all strings that satisfy certain conditions

51 Views Asked by At

Find all strings $w \in \{0,1,2\}^n$ such that

1) each number occurs at least once

2) $0$ does not occur as the first digit, $1$ does not occur as the second digit and $2$ does not occur as the third digit.

I know a solution using the inclusion and exclusion principle.

Am looking for a solution using generating functions.