Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN PYTHON: Write a function possible _ study _ groups ( zbinis ) . The parameter zbinis is a list of Zoomerbinis of the same

IN PYTHON:
Write a function possible_study_groups(zbinis). The parameter zbinis is a list of Zoomerbinis of the same form as in Task 2.
The function should return a list representing all the possible ways a valid study group could be chosen from zbinis. Each element is a tuple where:
The first element is a tuple of indices representing a group. This tuple should contain exactly three or four unique indices into the zbinis list in ascending order.
The second element is a score for the group, derived using a "points" system (described below).
For example, if zbinis was of length four, there could be up to five tuples of indices in the result with the first element in each being: (0,1,2,3),(0,1,2),(0,1,3),(0,2,3) and (1,2,3)
Each group's score (the second element in each returned tuple) is derived using a "points" system according to the following rules:
Add three points for each subject shared by all members of the group, and;
Add one point if the group has three members, or two points if the group has four members.
The returned groups should be sorted in descending order using the above scoring system, that is, higher scored groups should come before lower scored groups in the resulting list.
If there is ever a tie in scores, the group's indices should be used as a tiebreaker. Each index should be considered in turn (left to right) until one facilitates a tiebreak. For example, the grouping (0,2,3) should come before (1,2,3), and (0,1,2) should come before (0,1,3).
Groups that are invalid as per the same rules as in Task 2 should be excluded from the returned list altogether. A working version of the respective valid_study_group(zbinis, group) function has been provided to help you with this task.
Example Calls:
>>> print(possible_study_groups([(198,['FoC']),(138,['FoC', 'Calc 1']),(14,['FoC', 'Calc 1']),(66,['Calc 1'])]))
[((0,1,2),4),((1,2,3),4)]
>>> print(possible_study_groups([(198,['FoC']),(138,['FoC', 'Calc 1']),(14,['FoC']),(66,['FoC'])]))
[((0,1,2,3),5),((0,1,2),4),((0,1,3),4),((0,2,3),4),((1,2,3),4)]
>>> print(possible_study_groups([(198,['FoC']),(138,['Calc 1']),(14,['Calc 1']),(66,['FoC'])]))
[]

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions