Netguru interview question

Code challenge to be solved at home