It is possible to place 8 queens on an 8×8 chessboard so that no two queens threaten each other. Thus, it requires that

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

It is possible to place 8 queens on an 8×8 chessboard so that no two queens threaten each other. Thus, it requires that

Post by answerhappygod »

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 consistsof eight 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.
Use the following code 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 listcomprehension to get input data x.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