RTB House interview question

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