Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
With a trick solution in Clear category for Pawn Brotherhood by Ekaterina_Hostinetska
def safe_pawns(pawns: set) -> int:
horizontal = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
vertical = [1, 2, 3, 4, 5, 6, 7, 8]
positions = set()
for pos in pawns:
positions.add((horizontal.index(pos[0]), vertical.index(int(pos[1]))))
count = 0
for pawn in positions:
left = (pawn[0] - 1, pawn[1] - 1)
right = (pawn[0] + 1, pawn[1] - 1)
if left in positions or right in positions:
count += 1
return count
Aug. 16, 2021