Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Pawn Brotherhood solution in Clear category for Pawn Brotherhood by bamb00dark
def safe_pawns(pawns):
ranks = ('1', '2', '3', '4', '5', '6', '7', '8')
files = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
count = 0
for pawn in pawns:
x, y = pawn
col = files.index( x )
row = ranks.index( y )
defensePawns = []
if col - 1 >= 0 and row - 1 >= 0:
defensePawns.append( files[col-1] + ranks[row-1] )
if col + 1 <= 7 and row - 1 >= 0:
defensePawns.append( files[col+1] + ranks[row-1] )
if any(p for p in defensePawns if p in pawns):
count += 1
return count
Jan. 31, 2015