Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def convertChesstoDigit(placeCh):
- digCh=[]
- digCh.append(1+ord(placeCh[0])-ord('a'))
- digCh.append(int(placeCh[1]))
- return digCh
- def bishopCovers(n1,n2):
- coveredByB=[]
- for i in range(-8,9):
- b1=n1+i
- b2=n2+i
- c1=n1+i
- c2=n2-i
- if 1<=b1 and b1<=8 and 1<=b2 and b2<=8:
- coveredByB.append([b1,b2])
- if 1<=c1 and c2<=8 and 1<=c2 and c2<=8:
- coveredByB.append([c1,c2])
- return coveredByB
- def bishopAndPawn(bishop, pawn):
- bish1,bish2=convertChesstoDigit(bishop)
- pawn1,pawn2=convertChesstoDigit(pawn)
- if [pawn1,pawn2] in bishopCovers(bish1,bish2):
- return True
- else:
- return False
Advertisement
Add Comment
Please, Sign In to add comment