Question d’entretien chez Swiss Re

Can you solve the following coding problem?