Book Systems interview question

A logic question and a programming question.