Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple and Educational Solution solution in Clear category for Pawn Brotherhood by timothy.nilsson
def safe_pawns(pawns: set) -> int:
safe_pawns = 0
for i in pawns:
safe_pos1 = chr(ord(i[0]) + 1) + str(int(i[1]) - 1)
safe_pos2 = chr(ord(i[0]) - 1) + str(int(i[1]) - 1)
if safe_pos1 in pawns:
safe_pawns += 1
elif safe_pos2 in pawns:
safe_pawns += 1
print(safe_pawns)
return safe_pawns
return 0
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"})
print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")
Nov. 22, 2018
Comments: