Skip to content

Instantly share code, notes, and snippets.

@cggonzal
Created January 6, 2019 20:29
Show Gist options
  • Save cggonzal/a55024a2382d261ac8613b0b1ec2742e to your computer and use it in GitHub Desktop.
Save cggonzal/a55024a2382d261ac8613b0b1ec2742e to your computer and use it in GitHub Desktop.
def attackViaCol(self,pos):
for queen in self.queenPositions:
if(pos[1] == queen[1] and queen != pos): # last inqueality checks to make sure you arent comparing the same queen
return True
return False
def attackViaRow(self,pos):
for queen in self.queenPositions:
if(pos[0] == queen[0] and queen != pos):
return True
return False
def attackViaDiagonal(self,pos):
for queen in self.queenPositions:
if (abs(queen[0] - pos[0]) == abs(queen[1] - pos[1]) and queen != pos):
return True
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment