Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Pawn Brotherhood by tokiojapan55
def safe_pawns(pawns: set) -> int:
safe = 0
for pawn in pawns:
col = "abcdefgh".find(pawn[0])
row = int(pawn[1]) - 1
if row > 0:
if col > 0:
p = chr(ord('a') + col - 1) + str(row)
if p in pawns:
safe += 1
continue
if col < 7:
p = chr(ord('a') + col + 1) + str(row)
if p in pawns:
safe += 1
continue
return safe
June 22, 2020