Pregunta de entrevista de Jane Street

Snakes and ladders variant coding question