Cody

Solution 1703017

Submitted on 5 Jan 2019 by Nikolaos Nikolaou
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
x = [1:4]; y_correct = [1 0 0 0; 0 2 0 0; 0 0 3 0; 0 0 0 4]; assert(isequal(diag_array(x),y_correct))

t1 = 4 t2 = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 i = 1 t2 = 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 t2 = 1 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 t2 = 1 0 0 0 0 2 0 0 0 0 3 0 0 0 0 0 t2 = 1 0 0 0 0 2 0 0 0 0 3 0 0 0 0 4 y = 1 0 0 0 0 2 0 0 0 0 3 0 0 0 0 4

2   Pass
x = [100 23 3.14 12 200]; y_correct = [100.0000 0 0 0 0; 0 23.0000 0 0 0; 0 0 3.1400 0 0; 0 0 0 12.0000 0; 0 0 0 0 200.0000] assert(isequal(diag_array(x),y_correct))

y_correct = 100.0000 0 0 0 0 0 23.0000 0 0 0 0 0 3.1400 0 0 0 0 0 12.0000 0 0 0 0 0 200.0000 t1 = 5 t2 = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 i = 1 t2 = 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 t2 = 100 0 0 0 0 0 23 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 t2 = 100.0000 0 0 0 0 0 23.0000 0 0 0 0 0 3.1400 0 0 0 0 0 0 0 0 0 0 0 0 t2 = 100.0000 0 0 0 0 0 23.0000 0 0 0 0 0 3.1400 0 0 0 0 0 12.0000 0 0 0 0 0 0 t2 = 100.0000 0 0 0 0 0 23.0000 0 0 0 0 0 3.1400 0 0 0 0 0 12.0000 0 0 0 0 0 200.0000 y = 100.0000 0 0 0 0 0 23.0000 0 0 0 0 0 3.1400 0 0 0 0 0 12.0000 0 0 0 0 0 200.0000