Problem

Source:

Tags: combinatorics, Coloring



The wizard Gandalf has a necklace that is shaped like a row of magic pearls. The necklace has $2019$ pearls, $2018$ are black and the last one is white. Everytime that the magician Gandalf touches the necklace, the following occurs: the pearl in position $i$ is move to position $i-1$, for $1 <i <2020$, furthermore the pearl in position $1$ moves to position $2019$. But something else happens, if the pearl in position $1$ now is white, then the last pearl turns white without the need for Gandalf to touch the necklace again. How many times does Gandalf have to touch the necklace to be sure that all pearls are white?