Problem

Source: 1st Girls in Mathematics Tournament 2019 p3 (Brazil) / Torneio Meninas na Matematica (TM^2 )

Tags: number theory, Digits



We say that a positive integer N is nice if it satisfies the following conditions: $\bullet$ All of its digits are $1$ or $2$ $\bullet$ All numbers formed by $3$ consecutive digits of $N$ are distinct. For example, $121222$ is nice, because the $4$ numbers formed by $3$ consecutive digits of $121222$, which are $121,212,122$ and $222$, are distinct. However, $12121$ is not nice. What is the largest quantity possible number of numbers that a nice number can have? What is the greatest nice number there is?