Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
native_pawn_brotherhood solution in Clear category for Pawn Brotherhood by Jon_Red
def safe_pawns(pawns:set)->int:
safe=lambda x:{chr(ord(x[0])+y)+str(int(x[1])-1)for y in(1,-1)}
return sum(any(safe(pawn)&pawns)for pawn in pawns)
if __name__=='__main__':
# self-checks
assert safe_pawns({'b4','d4','f4','c3','e3','g5','d2'})==6
assert safe_pawns({'b4','c4','d4','e4','f4','g4','e5'})==1
July 23, 2020
Comments: