Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
I feel fullfilled solution in Clear category for Pawn Brotherhood by Adrian_W
def safe_pawns(pawns):
list=[]
for i in range(0, len(pawns)):
list.append(pawns.pop())
size=len(list)
safe=0
isSafe=False
for i in range(0,size):
isSafe=False
for j in range (0,size):
if ord(list[j][1])+1==ord(list[i][1]) and abs(ord(list[i][0])-ord(list[j][0]))==1:
isSafe=True
if isSafe:
safe+=1
return 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. 11, 2016
Comments: