Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Pawn Brotherhood by Julita_Pogorzelska
def safe_pawns(pawns):
letters=["a", "b", "c", "d", "e", "f", "g", "h"]
licznik=0
x=""
y=""
for pawn in pawns:
letter=pawn[0]
index=letters.index(letter)
if pawn[1]=="1":
x=""
y=""
elif pawn[0]=="a":
x=""
y=(letters[index+1], str(int(pawn[1])-1))
elif pawn[0]=="h":
x=(letters[index-1], str(int(pawn[1])-1))
y=""
else:
x=(letters[index-1], str(int(pawn[1])-1))
y=(letters[index+1], str(int(pawn[1])-1))
x="".join(x)
y="".join(y)
if x in pawns or y in pawns:
licznik +=1
print(pawns)
print(pawn)
print(x)
print(y)
print(licznik)
return licznik
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
print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")
Dec. 27, 2017