Answered step by step
Verified Expert Solution
Link Copied!

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, i.e. no two members share the same attribute value.
Additionally,
A valid group can only have either 3 or 4 members, and;
Each member must study at least one subject in common with every other member of the group.
Write a function valid_study_group(zbinis, 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 (type_id, subjects) tuple, where type_id is a Zoomerbini type ID (0 to 255 inclusive) and subjects is a list of non-empty 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 zbini_attrs(type_id) function from Task 1 has been provided to help you with this task.
Example Calls:
>>> example_zbinis =[(0,['FoC', 'Calc 1', 'Logic']),(108,['FoA', 'Calc 2', 'Logic']),(148,['FoC', 'Calc 1', 'Logic']),(248,['FoC', 'Calc 1', 'Logic']),(0,['Calc 2', 'History', 'Politics']),(108,['FoC', 'Calc 1', 'Logic'])]
>>> valid_study_group(example_zbinis, (0,1,3))
(True,1)
>>> valid_study_group(example_zbinis, (0,1,5))
(False, None)
>>> valid_study_group(example_zbinis, (0,1,2,3))
(True,1)
>>> valid_study_group(example_zbinis, (1,2,3,4))
(False, None)

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

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions

Question

List and explain five unique components of a GUI screen.

Answered: 1 week ago