Fortinet Interview Question

Write code for the problem [i just made up]