This problem is closely related to Problem 2189, Order of things - 1 and Problem 2190, Order of things - 2. For the details, see the description for those problems. Basically, we have to find the order in which to execute tasks of which the results and prerequisites depend on each other.
The dependencies of the tasks on each other is expressed in a matrix, where each row corresponds to the execution of a task, and each column to the dependency.
A B C D E A 0 0 0 0 0 B 0 0 0 0 0 C 0 1 0 0 0 D 0 1 1 0 0 E 1 0 0 0 0
The 1 on row C, column B, indicates that task C depends on task B.
The grouping of tasks is expressed as an input vector with groups assigned an integer value > 0, e.g.
[ 1 1 2 3 3 ]
Return the new row/column order as a numeric row-vector, referring to the rows/columns of the input matrix. If multiple orders exist, return them all as rows of a matrix. In this example:
[ 1 2 3 4 5 1 2 3 5 4 2 1 3 4 5 2 1 3 5 4 ]
If no order fulfilling the dependencies exists, return an empty vector.
I don't understand the grouping task vector coding.
In test case 1, how can 4 be done before 3? Two rows of order_correct have 4 before 3.
If I am interpreting correctly, tests 1, 3, and 5 might be incorrectly defined. In test 1, job4 depends on job3 (dependencies(4,3)==1) so the solution [4 3 5 2 1] would not be correct. Similarly, in test 3, job1 depends on job2 so [4 3 1 5 2] would not seem correct, etc. Am I misinterpreting?
sorry - had to try out the freepass problem. :)
Make the vector [1 2 3 4 5 6 7 8 9 10]
28174 Solvers
Determine whether a vector is monotonically increasing
8899 Solvers
Find all elements less than 0 or greater than 10 and replace them with NaN
11255 Solvers
5054 Solvers
Wayfinding 4 - Crossing, level 2
2 Solvers