HackerRank challenge: code a bot such that it eliminates as many possible blocks from the grid