Pregunta de entrevista de Inventia

No proper interview, just a coding assignment to solve.