Pergunta de entrevista da empresa Hopper

Simplified version of a problem that Hopper had to solve