Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Easy and clear soultion solution in Clear category for Pawn Brotherhood by piotr.sawicki
def safe_pawns(pawns):
# first of all, let's check which fields are "attacked" by each pawn
attacked_fields = set()
for i in pawns:
attacked_fields.add(chr(ord(i[0]) + 1) + str(int(i[1]) + 1))
attacked_fields.add(chr(ord(i[0]) - 1) + str(int(i[1]) + 1))
# returns intersection of two sets: attacked field and field where pawns are located
return len(attacked_fields & pawns)
Oct. 30, 2017