Cody

Problem 2732. Construct a precedence graph from a code segment

Solution 552906

Submitted on 6 Jan 2015
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
%% C = {'a=1;' 'b=1;' 'c=a+b;' 'c=c+1;'}; mat = [0 0 1 1; 0 0 1 1; 0 0 0 1; 0 0 0 0]; assert(isequal(pGraph(C),mat))

Error: Assertion failed.

2   Fail
%% C = {'a=1;' 'a=1;' 'c=1;' 'c=1;'}; mat = [0 0 0 0; 0 0 0 0; 0 0 0 0; 0 0 0 0]; assert(isequal(pGraph(C),mat))

Error: Assertion failed.

3   Fail
%% C = {'a=1;' 'a=1;' 'c=a+1;' 'c=a+1;'}; mat = [0 0 0 0; 0 0 1 1; 0 0 0 0; 0 0 0 0]; assert(isequal(pGraph(C),mat))

Error: Assertion failed.

4   Fail
%% C = {'a=1;' 'b=a+2;' 'c=b+1;' 'd=c+1;'}; mat = double(~tril(ones(4))) assert(isequal(pGraph(C),mat))

Error: Assertion failed.