Pergunta de entrevista da empresa Book Systems

A logic question and a programming question.