Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function friendly_knights() which takes in two squares and tells whether or not two knights on those squares are threatening each other. We want

Write a function friendly_knights() which takes in two squares and tells whether or not two knights on those squares are threatening each other. We want it to return True if the knights 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_knights((0,0),(1,2)) False >>> friendly_knights((0,0),(1,3)) True >>> friendly_knights((0,0),(2,2)) True

Write a function friendly_group() which takes in a list or tuple of positions and also takes in a function. When given a function that tells whether pairs of a certain piece type are fiendly, friendly_group() should return False in any pair of DIFFERENT pieces of that type in those positions are threatening each other. Otherwise it should return True.

>>> friendly_group([(0,0),(1,0),(1,1),(2,0)],friendly_knights) True

>>> friendly_group([(0,0),(1,0),(1,1),(2,1)],friendly_kings) False

>>> friendly_group([(0,0),(1,0),(1,1),(2,1)],friendly_rooks) False

>>> friendly_group([(0,0),(1,2),(2,4)],friendly_rooks) True >>> friendly_group([(0,0),(1,2),(2,4)],friendly_kings) True >>> friendly_group([(0,0),(1,2),(2,4)],friendly_knights) False

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

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago