Fluentgrid Interview Question

To solve some puzzles,write some pseudo codes