I have previously had this question answered in a way that didnot follow the instructions provided, but I was unable to provide acomment
It is possible to place 8 queens on an 8×8 chessboard so that notwo queens threaten each other. Thus, it requires that no twoqueens share the same row, column, or diagonal.
Write a Python program that, given a placement of 8 queens onthe chessboard , prints YES if there is a pair of queens thatviolates this rule and otherwise prints NO. The input consists ofeight coordinate pairs, one pair per line, with each pair givingthe position of a queen on a standard chessboard with rows andcolumns numbered from 1 to 8.
You must use the code below as a base:def check_queens_chessboard(x, y):
(INSERT YOUR CODE HERE)x = []y = []inputs in range(8):a_list = [int(s) for s in input().split()] # Use list comprehensionto get input datax.append(a_list[0])y.append(a_list[1])print(check_queens_chessboard(x, y))Example input:1 5
2 3
3 1
4 7
5 2
6 8
7 6
8 4
Example output: NO
I have previously had this question answered in a way that did not follow the instructions provided, but I was unable to
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am