Cody

# Problem 2192. Order of things - 4

Solution 440025

Submitted on 8 May 2014 by Brandon
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
dependencies = [ 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 ]; groups = [ 3 1 2 1 2 ]; order = calculation_order(dependencies,groups); order_correct = [ 3 2 5 4 1 3 5 2 4 1 5 4 2 3 1 ]; assert(isequal(sortrows(order_correct),sortrows(order)));

You just got a free pass. Congrats!

2   Pass
%% dependencies = [ 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 ]; groups = [ 3 1 1 2 2 ]; order = calculation_order(dependencies,groups); order_correct = [ 3 4 2 5 1 3 4 5 2 1 5 3 4 2 1 ]; assert(isequal(sortrows(order_correct),sortrows(order)));

You just got a free pass. Congrats!

3   Pass
%% dependencies = [ 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 ]; groups = [ 1 3 2 1 2 ]; order = calculation_order(dependencies,groups); order_correct = [ 2 1 4 5 3 5 1 4 2 3 4 1 3 2 5 ]; assert(isequal(sortrows(order_correct),sortrows(order)));

You just got a free pass. Congrats!

4   Pass
%% dependencies = [ 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 ]; groups = [1 2 2 2 2]; order = calculation_order(dependencies,groups); order_correct = [ 1 2 3 4 5 ]; assert(isequal(sortrows(order_correct),sortrows(order)));

You just got a free pass. Congrats!

5   Pass
%% dependencies = [ 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 ]; groups = [ 1 3 4 2 5 ]; order = calculation_order(dependencies,groups); assert(isempty(order));

You just got a free pass. Congrats!

6   Pass
%% dependencies = [ 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 ]; groups = [ 1 3 2 1 2 ]; order = calculation_order(dependencies,groups); order_correct = [ 1 2 4 5 3 1 2 3 5 4 1 5 4 2 3 1 5 3 2 4 1 4 3 2 5 1 3 4 2 5 5 4 3 2 1 5 3 4 2 1 ]; assert(isequal(sortrows(order_correct),sortrows(order)));

You just got a free pass. Congrats!

7   Pass
%% dependencies_ = ones(randi(10)); dependencies_ = dependencies_-triu(dependencies_); order_ = randperm(size(dependencies_,1)); dependencies = dependencies_(order_,order_); order_ = 0; order = calculation_order(dependencies,1:size(dependencies_,1)); ordered = dependencies(order,order); assert(~nnz(triu(ordered-diag(diag(ordered))))); order = calculation_order(dependencies,ones(1,size(dependencies_,1))); ordered = dependencies(order,order); assert(~nnz(triu(ordered-diag(diag(ordered)))));

You just got a free pass. Congrats!