Pregunta de entrevista de RTB House

Quick programming task using pseudo code and then programming it using php.