Answered step by step
Verified Expert Solution
Question
1 Approved Answer
IN PYTHON: While Zoomerbinis are usually quite amicable with one another, they have a rather specific set of preferences when it comes to forming study
IN PYTHON:
While Zoomerbinis are usually quite amicable with one another, they have a rather specific set of preferences when it comes to forming study groups! Specifically, a study group is valid if for each of the four attributes:
All members have the same attribute value, or;
All members have unique attribute values, ie no two members share the same attribute value.
Additionally,
A valid group can only have either or members, and;
Each member must study at least one subject in common with every other member of the group.
Write a function validstudygroupzbinis group that computes the validity of a given study group of Zoomerbinis, as per the above definition.
The parameter zbinis will be a list of Zoomerbinis, each represented as a typeid subjects tuple, where typeid is a Zoomerbini type ID to inclusive and subjects is a list of nonempty strings denoting the subjects the respective Zoomerbini is studying.
The parameter group will be a tuple of indices into the zbinis list and reflects the group of Zoomerbinis being checked for validity zbinis may be of a different length to group Note that while Zoomerbinis in a group may share the same type IDs, they must be distinct individuals in zbinis. In other words, if an index appears more than once in group, the group is invalid.
Your function should return a tuple containing two elements:
A boolean value denoting the validity of the respective group True if the group is valid or False if not
A positive integer representing the number of subjects all members of the group share in common with one another, or otherwise None if the group is not valid.
A working version of the zbiniattrstypeid function from Task has been provided to help you with this task.
Example Calls:
examplezbinis FoC 'Calc 'Logic'FoA 'Calc 'Logic'FoC 'Calc 'Logic'FoC 'Calc 'Logic'Calc 'History', 'Politics'FoC 'Calc 'Logic'
validstudygroupexamplezbinis,
True
validstudygroupexamplezbinis,
False None
validstudygroupexamplezbinis,
True
validstudygroupexamplezbinis,
False None
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