Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WRITE IN PYTHON:In this task you will finally allocate the Zoomerbinis to their study groups! Write a function alloc _ study _ groups ( zbinis

WRITE IN PYTHON:In this task you will finally allocate the Zoomerbinis to their study groups!
Write a function alloc_study_groups(zbinis) where the parameter zbinis is a list of Zoomerbinis, each represented as a (type_id, subjects) tuple (this is again of the same form as in the previous two tasks). The function should compute a set of groups of zbinis such that the number of Zoomerbinis without a group is minimised. We call this an optimal grouping.
The return value must be a list of tuples of indices into the zbinis list, where each tuple corresponds to a valid group in descending score order (following the same ordering rules as in Task 3). Importantly, a Zoomerbini cannot be allocated to more than one group, that is, any index in the result should appear at most once.
In the case that there are multiple optimal groupings, the grouping with the highest combined score out of these should be returned. This score is computed by summing up all the individual group scores that make up a given grouping (each group should be scored using the same points system as described in Task 3).
If there is still a tie between optimal groupings after considering combined scores, your function should preference the grouping with the smallest minimum index. For example, in the grouping [(2,3,4),(6,7,9)] the minimum index is 2, and hence should be preferred over [(3,4,5),(6,7,9)] which has a minimum index of 3. If more than one optimal grouping has the same minimum index, the second-to-minimum index should be used to tiebreak instead (or the third-to-minimum if there's a tie on both the minimum and second-to-minimum indices, etc). No further tiebreaking beyond this point is required.
Since this is a computationally expensive problem to solve, you may assume the length of zbinis will be at most 10. A working version of the possible_study_groups(zbinis) function has been provided to help you with this task.
Example Calls:
>>> print(alloc_study_groups([(198,['FoC']),(198,['FoC']),(138,['FoC']),(14,['FoC'])]))
[(0,2,3)]
>>> print(alloc_study_groups([(198,['FoC']),(138,['FoC', 'Calc 1']),(14,['FoC', 'Calc 1']),(66,['FoC', 'Calc 1'])]))
[(0,1,2,3)]
>>> print(alloc_study_groups([(198,['FoC', 'Logic']),(138,['Calc 1']),(14,['Calc 1']),(66,['FoC', 'Logic']),(10,['FoC', 'Logic']),(142,['FoC', 'Logic']),(66,['Calc 1'])]))
[(0,3,4,5),(1,2,6)]

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_2

Step: 3

blur-text-image_3

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

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions

Question

Contrast compensation and overcompensation in Adlers theory.

Answered: 1 week ago