Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please do Q 2 , Q 3 and Q 4 in python? Congratulations on your acceptance to the organising committee of the 2

Can you please do Q2, Q3 and Q4 in python?
Congratulations on your acceptance to the organising committee of the 2024 CAB203 Bonkers tournament!
Bonkers is an extremely exciting and fictitious game.
There are many tasks that need to be done, which have been distributed amongst the organising committee
members. Your acumen with discrete structures is well known, and hence you have been assigned several
organisational tasks which will benefit from some computerisation.
All tasks are intended to make significant use of graph theoretic tools and problems.
The tournament structure needs to be set; that is to say, who plays who. For this tournament a
structure is used where all games are set at the beginning. Another committee member will propose
the tournament structure and your job is to determine whether it has the required properties. The
committee has determined that the following properties are sufficient:
For every pair of distinct players, either they play against each other, or there are at least two
other players that they both play against.
All players have the same number of games.
So for example, if Alice and Bob don't play against each other then it's still OK as long as they both
play against two players in common, say, Charlie and Denise.
Your job is to find a method that, given a tournament structure, determines whether the above prop-
erties hold.
Implement your method in a Python function like so:
def gamesOK(games):
where games is a set of proposed games to play, given as pairs of players, like so:
games ={("Alice", "Bob"),("Charlie", "Bob")}
Note that the order of the players in a particular game does not matter: ('Alice','Bob') specifies
the same game as ('Bob', 'Alice'). You may assume that in the games given no player plays against
themselves, every player plays in at least one game, there is at least one player, and no game is given
more than once.
Your function should return True if the required property holds for the games given, otherwise False.
All Bonkers games must have a referee, but the referee for each game cannot have any conflicts of
interest for the game. In particular, the referee cannot be a player in the game, and the referee must
also declare any other conflicts of interest (eg. cannot be a player's relative, friend, boss, etc..). In
order to minimise the burden on any individual referee, the policy is to assign each referee at most one
game.
Your task is to determine a method for assigning referees to games, given the games, referees, and
conflicts of interest for each referee. You must assign at most one game to each referee, and exactly
one referee to each game, or determine that it is impossible to do so.
Implement your solution as a Python function of the form
def referees (games, refereecsvfilename):
games is structured the same as in the previous question. refereecsvfilename is the name for a CSV
file which you should read to obtain the list of referees and their declared conflicts of interest. Below
is a sample CSV file showing the structure.
You may assume that for each referee there is exactly one row giving their conflicts of interest.
Your function should return a data structure of games and assigned referees similar to:
# dictionary of all (player1, player2) : referee
{('Ashley', 'Bob'): 'Rene' }
or None if it is not possible.
The games now need to be scheduled, which will happen in two steps. Your first task is to group
together games that can be played simultaneously into game groups. The requirements for the game
groups are:
People are not double-booked: each person is involved in at most one game in any game group.,
either as a player or referee
Games are played once: each game is in exactly one game group
Each game group will be played in a single time slot, so the committee wants the smallest number of
game groups possible.
Implement your solution as a Python function of the form
def gameGroups(assignedReferees):
where assignedReferees is in the same format as you returned in the previous question, i.e. as a
dictionary with games as keys and referees as values. Your output should be a schedule in a data
structure of the form
The previous question only dealt with which games can be played at the same time, but not on the
order of the game groups. The preference is that if a player is also a referee then they play all of their
games before refereeing. Your task is to determine if it is possible to order the game groups so that
this is true.
Implement your solution as a Python function of the form
def gameSchedule(assignedReferees, gameGroups):
where assignedReferees is as in the previous question, and gameGroups is of the form of the return
value in the previous question. Your function should return the game groups in the required order, in
the same format as the return value in the previous question, or None if there is no such order.
image text in transcribed

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

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

Describe t he t wo m ain t ypes of ex ercise. (p. 1 84)

Answered: 1 week ago