I have an array of sets that means that the items inside the set must finish before the actual one starts. For example:
before = [ {},
{1},
{},
{},
{2}];
I'm looking to make each line include the ones who go before recursively. So in this case, it should end up like this:
abans = [ {},
{1},
{},
{},
{1,2}];
I've tried generating a variable and creating the sets from blank, but I didn't manage to do it. Any ideas how I could do this?
CASE 1:
beforeis a variable.Let's take the following list of tasks:
We declare an array
beforeto hold the set of blocking tasks for each task:A task should never block on itself:
A task
iinherits the block-set of each taskjblocking taski:You can append:
And find all possible solutions:
CASE 2:
beforeis an input parameter.A task
ibelongs toabans[j]if it is contained inbefore[j], or there exists a taskkinabans[j]such thatiis inbefore[j].Encoding:
Output: