Question: 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_group() which takes in a list or tuple
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_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
Get step-by-step solutions from verified subject matter experts
