Pregunta de entrevista de Shell

Generic but logical solutions needed