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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started