Pergunta de entrevista da empresa Moen

The question was a fun puzzle.