Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Scheduling with constraints: We have 3 time slots and 6 classes A, B, C, D, E, F. The following class pairs cannot be scheduled together

Scheduling with constraints: We have 3 time slots and 6 classes A, B, C, D, E, F. The following class pairs cannot be scheduled together (A, B),(A, C),(A, E),(B, D), (C, E),(C, D),(D, F),(E, F). For each class, there are three variables. For example, for class A, there are a1,a2 and a3. If a1=True this means that class A is scheduled in period

1. Write all your functions in the following parts in python. In each part, make sure that the names of your functions match the names of the functions that we are asking you to write. Note that for each 2 part you can call functions from previous parts. There are two sets of test cases. The autograder on Gradescope will only reveal the results of one set of cases. You will not know the results of the other set of test cases. This is done to encourage you to test your own code. Note: Place all the functions in a single python file and make sure to name your python file ps3.py for the auto-grader to recognize and compile the file. Also, do not include any print statements or header documentation in the file. Use function names as required by each question.

a) Define a function s(x1,x2,x3) that outputs True if the class X is scheduled at least once. The first line in your code should be def s(x1, x2, x3)

b) Define a function n(x1,x2,x3) that outputs True if the class X is scheduled no more than once.

c) Define a function ns(x1,x2,x3) that outputs True if the class X is scheduled exactly once.

d) Define a function c(x1,x2,x3,y1,y2,y3) that outputs True if two classes X and Y are scheduled in different time slots.

e) Define a function isValid(a1, a2, a3, b1, b2, b3, c1, c2, c3, d1, d2, d3, e1, e2, e3, f1, f2, f3) that outputs True if the schedule is valid for classes A,B,C,D,E, and F.

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

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions