Fluentgrid interview question

To solve some puzzles,write some pseudo codes