Pregunta de entrevista de Jane Street

Had to do complex coding on excel