NVIDIA interview question

Russian peasant algorithm in Python or pseudo