Help with this game

can someone help me do the logic of this game, because i had tried and i cant.