Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Pawn Brotherhood by maxadamski
def issafe(a, b):
a = (ord(a[0]), int(a[1]))
b = (ord(b[0]), int(b[1]))
return (a[0] == b[0] - 1 or a[0] == b[0] + 1) and a[1] == b[1] + 1
def safe_pawns(pawns):
pawns = list(pawns)
safecount = 0
safepawns = []
for pawn1 in pawns:
for pawn2 in pawns:
if pawn1 != pawn2 and pawn1 not in safepawns:
if issafe(pawn1, pawn2):
safepawns.append(pawn1)
safecount += 1
return safecount
Oct. 20, 2017