Pergunta de entrevista da empresa FactSet

How would you simplify this code?