Question: #@title ` AND _ OR _ Scheduler ` implementation class AND _ OR _ Scheduler ( object ) : def _ _ init _ _
#@title ANDORScheduler implementation
class ANDORSchedulerobject:
def initself:
# It is up to you to implement the initialization.
### YOUR SOLUTION HERE
def addandtaskself t dependencies:
Adds an AND task t with given dependencies."""
### YOUR SOLUTION HERE
def addortaskself t dependencies:
Adds an OR task t with given dependencies."""
### YOUR SOLUTION HERE
@property
def doneself:
### YOUR SOLUTION HERE
@property
def availabletasksself:
Returns the set of tasks that can be done in parallel.
A task can be done if:
It is an AND task, and all its predecessors have been completed, or
It is an OR task, and at least one of its predecessors has been completed.
And of course, we don't return any task that has already been
completed."""
### YOUR SOLUTION HERE
def markcompletedself t:
Marks the task t as completed, and returns the additional
set of tasks that can be done and that could not be
previously done once t is completed."""
### YOUR SOLUTION HERE
def showself:
You can use the nx graph to display the graph. You may want to ensure
that you display AND and OR nodes differently."""
### YOUR SOLUTION HERE
# Tests points: Simple tests for AND nodes.
s ANDORScheduler
saddandtaskabc
assert savailabletasks bc
r smarkcompletedb
assert r set
assert savailabletasks c
r smarkcompletedc
assert r a
assert savailabletasks a
r smarkcompleteda
assert r set
assert savailabletasks set
# Tests points: Simple tests for OR nodes.
s ANDORScheduler
saddortaskabc
assert savailabletasks bc
r smarkcompletedb
# Now a becomes available.
assert r a
# But note that c is also available, even if useless.
assert savailabletasks ac
r smarkcompleteda
assert r set
assert savailabletasks c
r smarkcompletedc
assert r set
assert savailabletasks set
# Tests points: Tests with both AND and OR nodes.
s ANDORScheduler
saddandtaskabc
saddortaskbbb
saddortaskccc
r smarkcompletedb
assert savailabletasks bbcc
r smarkcompletedb
assert a not in savailabletasks
r smarkcompletedc
assert a not in savailabletasks
r smarkcompletedc
assert a in savailabletasks
s ANDORScheduler
saddortaskabc
saddandtaskbbb
saddandtaskccc
r smarkcompletedb
assert savailabletasks bcc
r smarkcompletedc
assert savailabletasks bc
r smarkcompletedc
assert savailabletasks bc
r smarkcompletedc
assert a in savailabletasks
can someone help me with this code. What do I even input at the parts where it says ###YOUR SOLUTION HERE to get through all of the tests? This is driving me nuts.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
