FactSet interview question

How would you simplify this code?