Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Pawn Brotherhood by voxes96
def safe_pawns(pawns):
array = []
safe = []
col = []
row = []
array = list(pawns)
for i in range(len(array)):
x = array[i]
c = int(x[0],18)
r = int(x[1])
col.append(c)
row.append(r)
for i in range(len(array)):
ct = col[i]
rt = row[i]
for j in range(len(array)):
if(rt-1 == row[j] and (ct-1 == col[j] or ct+1 == col[j])):
if(safe.count(array[i])==0):
safe.append(array[i])
return len(safe)
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert safe_pawns({"b4", "d4", "f4", "c3", "e3", "g5", "d2"}) == 6
assert safe_pawns({"b4", "c4", "d4", "e4", "f4", "g4", "e5"}) == 1
Oct. 26, 2016