Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Dangerous Bishops by mortonfox
def safe_squares(n: int, bishops: tuple[int, int]) -> int:
return sum(all(abs(row-x) != abs(col-y) for x, y in bishops) for row in range(n) for col in range(n))
print("Example:")
print(safe_squares(10, []))
# These "asserts" are used for self-checking
assert safe_squares(10, []) == 100
assert safe_squares(4, [(2, 3), (0, 1)]) == 11
assert safe_squares(8, [(1, 1), (3, 5), (7, 0), (7, 6)]) == 29
print("The mission is done! Click 'Check Solution' to earn rewards!")
Dec. 27, 2023