Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Pawn Brotherhood by Daniel_Pereira
def safe_pawns(pawns):
def pawn_capture(square):
files = "#abcdefgh#"
rows = "#12345678#"
f = files.index(square[0])
r = rows.index(square[1])
squares = (files[f-1] + rows[r+1], files[f+1] + rows[r+1])
return [s for s in squares if "#" not in s]
safe = set()
for p in pawns:
safe.update(pawn_capture(p))
return len(safe & pawns)
Jan. 1, 2015
Comments: