Cody

Solution 419909

Submitted on 18 Mar 2014 by Samuel Walladge
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 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 ]; groups = [ 3 3 1 2 1 ]; order = calculation_order(dependencies,groups); order_correct = [ 5 3 4 2 1 5 3 4 1 2 4 3 5 2 1 4 3 5 1 2 ]; assert(isequal(sortrows(order_correct),sortrows(order)));

You just got a free pass. Congrats!

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

You just got a free pass. Congrats!

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

You just got a free pass. Congrats!

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

You just got a free pass. Congrats!

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

You just got a free pass. Congrats!

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

You just got a free pass. Congrats!

7   Pass
%% dependencies_ = ones(10+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!