Pergunta de entrevista da empresa Akamai

Since I am a chess player, a coding question was based on that