I have previously had this question answered in a way that did not follow the instructions provided, but I was unable to

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

I have previously had this question answered in a way that did not follow the instructions provided, but I was unable to

Post by answerhappygod »

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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply