Cody

Solution 671037

Submitted on 17 May 2015 by Aki Kangasmäki
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
%% user_solution = fileread('pascalMat.m'); assert(isempty(strfind(user_solution,'regexp'))); assert(isempty(strfind(user_solution,'2str'))); assert(isempty(strfind(user_solution,'str2'))); assert(isempty(strfind(user_solution,'interp'))); assert(isempty(strfind(user_solution,'printf'))); assert(isempty(strfind(user_solution,'assert')));

2   Pass
%% n = 0; P_correct = [ 1 ]; assert(isequal(pascalMat(n),P_correct));

P = 1

3   Pass
%% n = 1; P_correct = [ 1 0 1 1 ]; assert(isequal(pascalMat(n),P_correct));

P = 1 0 0 0 P = 1 0 1 0 P = 1 0 1 1

4   Pass
%% n = 2; P_correct = [ 1 0 0 1 1 0 1 2 1 ]; assert(isequal(pascalMat(n),P_correct));

P = 1 0 0 0 0 0 0 0 0 P = 1 0 0 1 0 0 0 0 0 P = 1 0 0 1 1 0 0 0 0 P = 1 0 0 1 1 0 1 0 0 P = 1 0 0 1 1 0 1 2 0 P = 1 0 0 1 1 0 1 2 1

5   Pass
%% n = 3; P_correct = [ 1 0 0 0 1 1 0 0 1 2 1 0 1 3 3 1 ]; assert(isequal(pascalMat(n),P_correct));

P = 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 P = 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 P = 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 P = 1 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 P = 1 0 0 0 1 1 0 0 1 2 0 0 0 0 0 0 P = 1 0 0 0 1 1 0 0 1 2 1 0 0 0 0 0 P = 1 0 0 0 1 1 0 0 1 2 1 0 1 0 0 0 P = 1 0 0 0 1 1 0 0 1 2 1 0 1 3 0 0 P = 1 0 0 0 1 1 0 0 1 2 1 0 1 3 3 0 P = 1 0 0 0 1 1 0 0 1 2 1 0 1 3 3 1

6   Pass
%% n = 4; P_correct = [ 1 0 0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