Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!