Pergunta de entrevista da empresa Morningstar

optimize a certain part of the code from the assignment