Pergunta de entrevista da empresa Philips

How would you make this function