Pregunta de entrevista de Scalio

asked to solve a logic problem