Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Pawn Brotherhood by sebastian009
def safe_pawns(pawns):
pawns_indexes = set()
pawns = list(pawns)
for p in pawns:
row = int(p[1])-1
col = ord(p[0])-97
pawns_indexes.add((row,col))
count = 0
for row,col in pawns_indexes:
issafe = ((row-1,col-1) in pawns_indexes) or ((row-1,col+1) in pawns_indexes)
if issafe:
count += 1
return count
Oct. 19, 2016