Pergunta de entrevista da empresa ISAM

Coding exercise given in the form of a problem written in a text file.