Pergunta de entrevista da empresa Accenture

Basic logic question (not programming related) followed by two explicit coding questions.