Cody

Problem 2189. Order of things - 1

Solution 2579463

Submitted on 18 Jun 2020
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   Fail
dependencies = [ 0 0 1 0 ]; order = calculation_order(dependencies); order_correct = [ 1 2 ]; assert(isequal(order_correct,order));

depen = 0 0 1 0 depen = 0 0 0 1

Output argument "order" (and maybe others) not assigned during call to "calculation_order". Error in Test1 (line 5) order = calculation_order(dependencies);

2   Fail
dependencies = [ 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 0 1 1 1 1 0 ]; order = calculation_order(dependencies); order_correct = [ 2 1 4 3 5 ]; assert(isequal(order_correct,order));

depen = 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 1 1 1 0 depen = 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 1 1 1 0 depen = 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 1 1 1 1 0 depen = 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 1 1 1 1 0 depen = 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 1 0 1 1 1

Output argument "order" (and maybe others) not assigned during call to "calculation_order". Error in Test2 (line 8) order = calculation_order(dependencies);

3   Fail
dependencies = [ 0 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 ]; order = calculation_order(dependencies); ordered = dependencies(order,order); assert(~nnz(triu(ordered-diag(diag(ordered)))));

depen = 1 1 1 1 0 1 0 1 1 0 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 depen = 1 0 1 1 1 1 0 1 1 0 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 depen = 1 0 1 1 1 1 0 0 1 1 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 depen = 1 0 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 depen = 1 0 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0

Output argument "order" (and maybe others) not assigned during call to "calculation_order". Error in Test3 (line 8) order = calculation_order(dependencies);

4   Fail
dependencies_ = tril(randi(2,10)-1); dependencies_ = dependencies_-diag(diag(dependencies_)); order_ = randperm(size(dependencies_,1)); dependencies = dependencies_(order_,order_); clear order_; order = calculation_order(dependencies); % [~,order] = sort(order_); assert(~nnz(triu(dependencies(order,order))));

Unable to perform assignment because the size of the left side is 10-by-3 and the size of the right side is 10-by-1. Error in calculation_order (line 9) depen(:,find(tar==min(tar)))=col2 ; Error in Test4 (line 6) order = calculation_order(dependencies);

5   Fail
dependencies_ = randi(2,10)-1; dependencies_ = dependencies_-triu(dependencies_); order_ = randperm(size(dependencies_,1)); dependencies = dependencies_(order_,order_); clear order_; % to prevent the evalin hack order = calculation_order(dependencies); % [~,order] = sort(order_); assert(~nnz(triu(dependencies(order,order))));

Unable to perform assignment because the size of the left side is 10-by-4 and the size of the right side is 10-by-1. Error in calculation_order (line 9) depen(:,find(tar==min(tar)))=col2 ; Error in Test5 (line 6) order = calculation_order(dependencies);

6   Fail
% n = 10; % dependencies_ = tril(randi(3,n)>1|diag(ones(1,n-1),-1))&~eye(n); % order_ = randperm(n); % dependencies = dependencies_(order_,order_); dependencies = [ 0 1 1 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 0 0 1 1 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 0 0 1 1 1 1 1 0 0 1 0 0 0 0 1 1 1 1 1 0 1 0 1 0 1 0 0 0 0 1 0 0 0 0 0 ]; order = calculation_order(dependencies); % [~,order_correct] = sort(order_); order_correct = [ 5 10 2 3 1 8 6 4 9 7 ]; assert(isequal(order,order_correct));

depen = 1 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 1 1 0 1 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1 0 1 0 1 1 0 0 0 0 0 0 0 0 0 depen = 1 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 1 1 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1 0 1 1 1 0 1 1 1 0 1 1 0 0 0 0 0 0 0 0 0 depen = 1 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 1 1 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 depen = 1 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 1 1 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0 0 0 0 1 0 1 1 1 0 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 depen = 1 0 1 1 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 0 0 0 0 0 1 1 1 1 1 1 0 1 0 1 0 0 0 0 0 0 0 0 0

Output argument "order" (and maybe others) not assigned during call to "calculation_order". Error in Test6 (line 17) order = calculation_order(dependencies);