Solving the student handshake problem (PDF)