Book Systems Interview Question

A logic question and a programming question.