Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python, Consider an m by n chessboard with the squares labeled (0,0),(0,1),...,(m-1,n-1). 1. Write a function friendly_pair() which takes in two squares and tells

Using Python, Consider an m by n chessboard with the squares labeled (0,0),(0,1),...,(m-1,n-1).

1. Write a function friendly_pair() which takes in two squares and tells whether or not two rooks on those squares are threatening each other. We want it to return True if the rooks are not threatening each other and False if they are. Note that this function does not need to take in the size of the board.

>>> friendly_rooks((0,0),(0,3))

False

>>> friendly_rooks((0,0),(3,3))

True

>>> friendly_rooks((0,0),(3,0)) False

2. Write a function friendly_group() which takes in a list or tuple of positions and returns False in any pair of DIFFERENT rooks in those positions are threatening each other. Otherwise it should return True.

>>> friendly_group(((0,0),(1,1)))

True

>>> friendly_group(((0,2),(1,1),(2,0)))

True

>>> friendly_group(((0,2),(1,1),(2,1)))

False

>>> friendly_group(((0,2),(1,1),(2,4),(3,3)))

True

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

KEY QUESTION Refer to Figure 3.6, page

Answered: 1 week ago