Example 1 · empty
- Arguments
- workers
1
queueLimit0
events[]
- Expected return
Empty list
Test data
- Input
{"workers":1,"queueLimit":0,"events":[]}- Expected output
[]
func ScheduleWorkers(workers, queueLimit int, events []Event) []SnapshotKind stringJob stringToken intJob stringToken intAccepted boolActive []RunWaiting []stringExamples encode events as [kind, job, token], active runs as {job, token}, and each snapshot as {accepted, active, waiting}.
The runner calls your functions directly; you do not need to parse JSON.
1
0
[]
Empty list
{"workers":1,"queueLimit":0,"events":[]}[]
2
1
[
[
"submit",
"b",
0
],
[
"submit",
"A",
0
],
[
"submit",
"t",
0
],
[
"submit",
"x",
0
],
[
"complete",
"b",
1
]
][
{
"accepted": true,
"active": [
{
"job": "b",
"token": 1
}
],
"waiting": []
},
{
"accepted": true,
"active": [
{
"job": "b",
"token": 1
},
{
"job": "A",
"token": 2
}
],
"waiting": []
},
{
"accepted": true,
"active": [
{
"job": "b",
"token": 1
},
{
"job": "A",
"token": 2
}
],
"waiting": [
"t"
]
},
{
"accepted": false,
"active": [
{
"job": "b",
"token": 1
},
{
"job": "A",
"token": 2
}
],
"waiting": [
"t"
]
},
{
"accepted": true,
"active": [
{
"job": "A",
"token": 2
},
{
"job": "t",
"token": 3
}
],
"waiting": []
}
]{"workers":2,"queueLimit":1,"events":[["submit","b",0],["submit","A",0],["submit","t",0],["submit","x",0],["complete","b",1]]}[{"accepted":true,"active":[{"job":"b","token":1}],"waiting":[]},{"accepted":true,"active":[{"job":"b","token":1},{"job":"A","token":2}],"waiting":[]},{"accepted":true,"active":[{"job":"b","token":1},{"job":"A","token":2}],"waiting":["t"]},{"accepted":false,"active":[{"job":"b","token":1},{"job":"A","token":2}],"waiting":["t"]},{"accepted":true,"active":[{"job":"A","token":2},{"job":"t","token":3}],"waiting":[]}]1
2
[
[
"submit",
"a",
0
],
[
"submit",
"b",
0
],
[
"submit",
"c",
0
],
[
"cancel",
"b",
0
],
[
"cancel",
"a",
0
],
[
"complete",
"a",
1
]
][
{
"accepted": true,
"active": [
{
"job": "a",
"token": 1
}
],
"waiting": []
},
{
"accepted": true,
"active": [
{
"job": "a",
"token": 1
}
],
"waiting": [
"b"
]
},
{
"accepted": true,
"active": [
{
"job": "a",
"token": 1
}
],
"waiting": [
"b",
"c"
]
},
{
"accepted": true,
"active": [
{
"job": "a",
"token": 1
}
],
"waiting": [
"c"
]
},
{
"accepted": true,
"active": [
{
"job": "c",
"token": 2
}
],
"waiting": []
},
{
"accepted": false,
"active": [
{
"job": "c",
"token": 2
}
],
"waiting": []
}
]{"workers":1,"queueLimit":2,"events":[["submit","a",0],["submit","b",0],["submit","c",0],["cancel","b",0],["cancel","a",0],["complete","a",1]]}[{"accepted":true,"active":[{"job":"a","token":1}],"waiting":[]},{"accepted":true,"active":[{"job":"a","token":1}],"waiting":["b"]},{"accepted":true,"active":[{"job":"a","token":1}],"waiting":["b","c"]},{"accepted":true,"active":[{"job":"a","token":1}],"waiting":["c"]},{"accepted":true,"active":[{"job":"c","token":2}],"waiting":[]},{"accepted":false,"active":[{"job":"c","token":2}],"waiting":[]}]1
0
[
[
"submit",
"a",
0
],
[
"cancel",
"a",
0
],
[
"submit",
"a",
0
],
[
"complete",
"a",
1
],
[
"complete",
"a",
2
]
][
{
"accepted": true,
"active": [
{
"job": "a",
"token": 1
}
],
"waiting": []
},
{
"accepted": true,
"active": [],
"waiting": []
},
{
"accepted": true,
"active": [
{
"job": "a",
"token": 2
}
],
"waiting": []
},
{
"accepted": false,
"active": [
{
"job": "a",
"token": 2
}
],
"waiting": []
},
{
"accepted": true,
"active": [],
"waiting": []
}
]{"workers":1,"queueLimit":0,"events":[["submit","a",0],["cancel","a",0],["submit","a",0],["complete","a",1],["complete","a",2]]}[{"accepted":true,"active":[{"job":"a","token":1}],"waiting":[]},{"accepted":true,"active":[],"waiting":[]},{"accepted":true,"active":[{"job":"a","token":2}],"waiting":[]},{"accepted":false,"active":[{"job":"a","token":2}],"waiting":[]},{"accepted":true,"active":[],"waiting":[]}]Separate active and waiting state makes both capacity bounds explicit. A dispatch token identifies an execution attempt rather than just a reusable job ID, so a late completion cannot finish a replacement. Processing explicit events models these ownership decisions deterministically; it does not test operating-system thread interleavings.
Using maps and a linked FIFO gives expected O(1) state transitions plus the cost of each required snapshot. A simple array queue may use linear removal; total output size is a necessary lower bound on runtime and storage.
Checking execution availability…
View inputs and expected outputs. Examples do not run your code.